源战役客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

225 lines
4.4 KiB

преди 4 седмици
  1. cc = cc or {}
  2. cc.ActionInstant = cc.ActionInstant or BaseClass(cc.FiniteTimeAction)
  3. function cc.ActionInstant:__init()
  4. self._classType = "ActionInstant"
  5. end
  6. function cc.ActionInstant:isDone()
  7. return true
  8. end
  9. function cc.ActionInstant:step(dt)
  10. self:update(1)
  11. end
  12. function cc.ActionInstant:update(time)
  13. -- nothing
  14. end
  15. --CallFunc start
  16. cc.CallFunc = cc.CallFunc or BaseClass(cc.ActionInstant)
  17. function cc.CallFunc:__init(call_back)
  18. self:initWithFunction(call_back)
  19. end
  20. function cc.CallFunc:initWithFunction( call_back )
  21. self.call_back = call_back
  22. end
  23. function cc.CallFunc:clone()
  24. return cc.CallFunc.New(self.call_back)
  25. end
  26. function cc.CallFunc:reverse()
  27. return self:clone()
  28. end
  29. function cc.CallFunc:update(time)
  30. if self.call_back then
  31. self.call_back()
  32. end
  33. end
  34. --CallFunc end
  35. --Place start
  36. cc.Place = cc.Place or BaseClass(cc.ActionInstant)
  37. function cc.Place:__init(new_x, new_y, new_z)
  38. self:initWithPosition(new_x, new_y, new_z)
  39. end
  40. function cc.Place:initWithPosition( new_x, new_y, new_z )
  41. self.new_x = new_x
  42. self.new_y = new_y
  43. self.new_z = new_z
  44. end
  45. function cc.Place:clone()
  46. return cc.Place.New(self.new_x, self.new_y, self.new_z)
  47. end
  48. function cc.Place:reverse()
  49. return self:clone()
  50. end
  51. function cc.Place:update(time)
  52. if not self._target then return end
  53. cc.Wrapper.SetLocalPosition(self._target, self.new_x, self.new_y, self.new_z)
  54. -- if self.new_x then
  55. -- self._target:SetVectorL(WidgetProperty.Position, self.new_x)
  56. -- end
  57. -- if self.new_y then
  58. -- self._target:SetVectorR(WidgetProperty.Position, self.new_y)
  59. -- end
  60. end
  61. --Place end
  62. --Show start
  63. cc.Show = cc.Show or BaseClass(cc.ActionInstant)
  64. function cc.Show:__init()
  65. end
  66. function cc.Show:clone()
  67. return cc.Show.New()
  68. end
  69. function cc.Show:reverse()
  70. return cc.Hide.New()
  71. end
  72. function cc.Show:update(time)
  73. cc.Wrapper.SetVisible(self._target, true)
  74. end
  75. --Show end
  76. --Hide start
  77. cc.Hide = cc.Hide or BaseClass(cc.ActionInstant)
  78. function cc.Hide:__init()
  79. end
  80. function cc.Hide:clone()
  81. return cc.Hide.New()
  82. end
  83. function cc.Hide:reverse()
  84. return cc.Show.New()
  85. end
  86. function cc.Hide:update(time)
  87. cc.Wrapper.SetVisible(self._target, false)
  88. end
  89. --Hide end
  90. --Delete start
  91. cc.Delete = cc.Delete or BaseClass(cc.ActionInstant)
  92. function cc.Delete:__init()
  93. end
  94. function cc.Delete:clone()
  95. return cc.Delete.New()
  96. end
  97. function cc.Delete:reverse()
  98. -- return cc.Show.New()
  99. end
  100. function cc.Delete:update(time)
  101. cc.Wrapper.Delete(self._target)
  102. end
  103. --Delete end
  104. --Alpha start
  105. cc.Alpha = cc.Alpha or BaseClass(cc.ActionInstant)
  106. function cc.Alpha:__init(new_alpha)
  107. self:initWithAlpha(new_alpha)
  108. end
  109. function cc.Alpha:initWithAlpha( new_alpha )
  110. self.new_alpha = new_alpha
  111. end
  112. function cc.Alpha:clone()
  113. return cc.Alpha.New(self.new_alpha)
  114. end
  115. function cc.Alpha:reverse()
  116. return self:clone()
  117. end
  118. function cc.Alpha:update(time)
  119. if not self._target then return end
  120. cc.Wrapper.SetAlpha(self._target, self.new_alpha)
  121. end
  122. --Alpha end
  123. --Scale start
  124. cc.Scale = cc.Scale or BaseClass(cc.ActionInstant)
  125. function cc.Scale:__init(scale_x, scale_y, scale_z)
  126. self:initWithScale(scale_x, scale_y, scale_z)
  127. end
  128. function cc.Scale:initWithScale( scale_x, scale_y, scale_z )
  129. self.scale_x = scale_x or 1
  130. self.scale_y = scale_y or 1
  131. self.scale_z = scale_z or 1
  132. end
  133. function cc.Scale:clone()
  134. return cc.Scale.New(self.scale_x, self.scale_y, self.scale_z)
  135. end
  136. function cc.Scale:update(time)
  137. if not self._target then return end
  138. cc.Wrapper.SetLocalScale(self._target, self.scale_x, self.scale_y, self.scale_z)
  139. end
  140. --Scale end
  141. --Text start
  142. cc.Text = cc.Text or BaseClass(cc.ActionInstant)
  143. function cc.Text:__init(new_txt)
  144. self:initWithText(new_txt)
  145. end
  146. function cc.Text:initWithText( new_txt )
  147. self.new_txt = new_txt
  148. end
  149. function cc.Text:clone()
  150. return cc.Text.New(self.new_txt)
  151. end
  152. function cc.Text:update(time)
  153. if not self._target then return end
  154. cc.Wrapper.SetText(self._target, self.new_txt)
  155. end
  156. --Text end
  157. --Sprite start
  158. cc.Sprite = cc.Sprite or BaseClass(cc.ActionInstant)
  159. function cc.Sprite:__init(sprite_name)
  160. self:initWithSprite(sprite_name)
  161. end
  162. function cc.Sprite:initWithSprite( sprite_name )
  163. self.sprite_name = sprite_name
  164. end
  165. function cc.Sprite:clone()
  166. return cc.Sprite.New(self.sprite_name)
  167. end
  168. function cc.Sprite:update(time)
  169. if not self._target then return end
  170. cc.Wrapper.SetSprite(self, self._target, self.sprite_name)
  171. end
  172. --Sprite end