CCActionFrame.h 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  1. /****************************************************************************
  2. Copyright (c) 2013-2017 Chukong Technologies Inc.
  3. http://www.cocos2d-x.org
  4. Permission is hereby granted, free of charge, to any person obtaining a copy
  5. of this software and associated documentation files (the "Software"), to deal
  6. in the Software without restriction, including without limitation the rights
  7. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. copies of the Software, and to permit persons to whom the Software is
  9. furnished to do so, subject to the following conditions:
  10. The above copyright notice and this permission notice shall be included in
  11. all copies or substantial portions of the Software.
  12. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  13. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  15. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  16. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  17. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  18. THE SOFTWARE.
  19. ****************************************************************************/
  20. #ifndef __ActionFRAME_H__
  21. #define __ActionFRAME_H__
  22. #include "math/CCGeometry.h"
  23. #include "2d/CCActionInterval.h"
  24. #include "editor-support/cocostudio/CocosStudioExport.h"
  25. namespace cocostudio {
  26. enum FrameType
  27. {
  28. kKeyframeMove = 0,
  29. kKeyframeScale,
  30. kKeyframeRotate,
  31. kKeyframeTint,
  32. kKeyframeFade,
  33. kKeyframeMax
  34. };
  35. enum class FrameEaseType
  36. {
  37. Custom = -1,
  38. LINERAR = 0,
  39. SINE_EASEIN,
  40. SINE_EASEOUT,
  41. SINE_EASEINOUT,
  42. QUAD_EASEIN,
  43. QUAD_EASEOUT,
  44. QUAD_EASEINOUT,
  45. CUBIC_EASEIN,
  46. CUBIC_EASEOUT,
  47. CUBIC_EASEINOUT,
  48. QUART_EASEIN,
  49. QUART_EASEOUT,
  50. QUART_EASEINOUT,
  51. QUINT_EASEIN,
  52. QUINT_EASEOUT,
  53. QUINT_EASEINOUT,
  54. EXPO_EASEIN,
  55. EXPO_EASEOUT,
  56. EXPO_EASEINOUT,
  57. CIRC_EASEIN,
  58. CIRC_EASEOUT,
  59. CIRC_EASEINOUT,
  60. ELASTIC_EASEIN,
  61. ELASTIC_EASEOUT,
  62. ELASTIC_EASEINOUT,
  63. BACK_EASEIN,
  64. BACK_EASEOUT,
  65. BACK_EASEINOUT,
  66. BOUNCE_EASEIN,
  67. BOUNCE_EASEOUT,
  68. BOUNCE_EASEINOUT,
  69. TWEEN_EASING_MAX = 10000
  70. };
  71. /**
  72. * @js NA
  73. * @lua NA
  74. */
  75. class CC_STUDIO_DLL ActionFrame: public cocos2d::Ref
  76. {
  77. public:
  78. /**
  79. * Default constructor
  80. */
  81. ActionFrame();
  82. /**
  83. * Default destructor
  84. */
  85. virtual ~ActionFrame();
  86. /**
  87. * Changes the index of action frame
  88. *
  89. * @param index the index of action frame
  90. */
  91. void setFrameIndex(int index);
  92. /**
  93. * Gets the index of action frame
  94. *
  95. * @return the index of action frame
  96. */
  97. int getFrameIndex();
  98. /**
  99. * Changes the time of action frame
  100. *
  101. * @param fTime the time of action frame
  102. */
  103. void setFrameTime(float fTime);
  104. /**
  105. * Gets the time of action frame
  106. *
  107. * @return fTime the time of action frame
  108. */
  109. float getFrameTime();
  110. /**
  111. * Changes the type of action frame
  112. *
  113. * @param frameType the type of action frame
  114. */
  115. void setFrameType(int frameType);
  116. /**
  117. * Gets the type of action frame
  118. *
  119. * @return the type of action frame
  120. */
  121. int getFrameType();
  122. /**
  123. * Changes the easing type.
  124. *
  125. * @param easingType the easing type.
  126. */
  127. void setEasingType(int easingType);
  128. /**
  129. * Gets the easing type.
  130. *
  131. * @return the easing type.
  132. */
  133. int getEasingType();
  134. /**
  135. * Gets the ActionInterval of ActionFrame.
  136. *
  137. * @param duration the duration time of ActionFrame
  138. *
  139. * @return ActionInterval
  140. */
  141. virtual cocos2d::ActionInterval* getAction(float duration);
  142. /**
  143. * Gets the ActionInterval of ActionFrame.
  144. *
  145. * @param duration the duration time of ActionFrame
  146. *
  147. * @param duration the source ActionFrame
  148. *
  149. * @return ActionInterval
  150. */
  151. virtual cocos2d::ActionInterval* getAction(float duration,ActionFrame* srcFrame);
  152. /**
  153. *Set the ActionInterval easing parameter.
  154. *
  155. *@param parameter the parameter for frame ease
  156. *
  157. */
  158. virtual void setEasingParameter(std::vector<float>& parameter);
  159. protected:
  160. /**
  161. * Gets the Easing Action of ActionFrame.
  162. *
  163. * @param action the duration time of ActionFrame
  164. *
  165. * @return ActionInterval
  166. */
  167. virtual cocos2d::ActionInterval* getEasingAction(cocos2d::ActionInterval* action);
  168. protected:
  169. int _frameType;
  170. int _frameIndex;
  171. float _fTime;
  172. FrameEaseType _easingType;
  173. std::vector<float> _Parameter;
  174. };
  175. /**
  176. * @js NA
  177. * @lua NA
  178. */
  179. class CC_STUDIO_DLL ActionMoveFrame:public ActionFrame
  180. {
  181. public:
  182. /**
  183. * Default constructor
  184. */
  185. ActionMoveFrame();
  186. /**
  187. * Default destructor
  188. */
  189. virtual ~ActionMoveFrame();
  190. /**
  191. * Changes the move action position.
  192. *
  193. * @param the move action position.
  194. */
  195. void setPosition(cocos2d::Vec2 pos);
  196. /**
  197. * Gets the move action position.
  198. *
  199. * @return the move action position.
  200. */
  201. cocos2d::Vec2 getPosition();
  202. /**
  203. * Gets the ActionInterval of ActionFrame.
  204. *
  205. * @param duration the duration time of ActionFrame
  206. *
  207. * @return ActionInterval
  208. */
  209. virtual cocos2d::ActionInterval* getAction(float duration);
  210. protected:
  211. cocos2d::Vec2 _position;
  212. };
  213. /**
  214. * @js NA
  215. * @lua NA
  216. */
  217. class CC_STUDIO_DLL ActionScaleFrame:public ActionFrame
  218. {
  219. public:
  220. /**
  221. * Default constructor
  222. */
  223. ActionScaleFrame();
  224. /**
  225. * Default destructor
  226. */
  227. virtual ~ActionScaleFrame();
  228. /**
  229. * Changes the scale action scaleX.
  230. *
  231. * @param the scale action scaleX.
  232. */
  233. void setScaleX(float scaleX);
  234. /**
  235. * Gets the scale action scaleX.
  236. *
  237. * @return the scale action scaleX.
  238. */
  239. float getScaleX();
  240. /**
  241. * Changes the scale action scaleY.
  242. *
  243. * @param rotation the scale action scaleY.
  244. */
  245. void setScaleY(float scaleY);
  246. /**
  247. * Gets the scale action scaleY.
  248. *
  249. * @return the scale action scaleY.
  250. */
  251. float getScaleY();
  252. /**
  253. * Gets the ActionInterval of ActionFrame.
  254. *
  255. * @param duration the duration time of ActionFrame
  256. *
  257. * @return ActionInterval
  258. */
  259. virtual cocos2d::ActionInterval* getAction(float duration);
  260. protected:
  261. float _scaleX;
  262. float _scaleY;
  263. };
  264. /**
  265. * @js NA
  266. * @lua NA
  267. */
  268. class CC_STUDIO_DLL ActionRotationFrame:public ActionFrame
  269. {
  270. public:
  271. /**
  272. * Default constructor
  273. */
  274. ActionRotationFrame();
  275. /**
  276. * Default destructor
  277. */
  278. virtual ~ActionRotationFrame();
  279. /**
  280. * Changes rotate action rotation.
  281. *
  282. * @param rotation rotate action rotation.
  283. */
  284. void setRotation(float rotation);
  285. /**
  286. * Gets the rotate action rotation.
  287. *
  288. * @return the rotate action rotation.
  289. */
  290. float getRotation();
  291. /**
  292. * Gets the ActionInterval of ActionFrame.
  293. *
  294. * @param duration the duration time of ActionFrame
  295. *
  296. * @return ActionInterval
  297. */
  298. virtual cocos2d::ActionInterval* getAction(float duration);
  299. /**
  300. * Gets the ActionInterval of ActionFrame.
  301. *
  302. * @param duration the duration time of ActionFrame
  303. *
  304. * @param duration the source ActionFrame
  305. *
  306. * @return ActionInterval
  307. */
  308. virtual cocos2d::ActionInterval* getAction(float duration,ActionFrame* srcFrame);
  309. public:
  310. float _rotation;
  311. };
  312. /**
  313. * @js NA
  314. * @lua NA
  315. */
  316. class CC_STUDIO_DLL ActionFadeFrame:public ActionFrame
  317. {
  318. public:
  319. /**
  320. * Default constructor
  321. */
  322. ActionFadeFrame();
  323. /**
  324. * Default destructor
  325. */
  326. virtual ~ActionFadeFrame();
  327. /**
  328. * Changes the fade action opacity.
  329. *
  330. * @param opacity the fade action opacity
  331. */
  332. void setOpacity(int opacity);
  333. /**
  334. * Gets the fade action opacity.
  335. *
  336. * @return the fade action opacity.
  337. */
  338. int getOpacity();
  339. /**
  340. * Gets the ActionInterval of ActionFrame.
  341. *
  342. * @param duration the duration time of ActionFrame
  343. *
  344. * @return ActionInterval
  345. */
  346. virtual cocos2d::ActionInterval* getAction(float duration);
  347. protected:
  348. float _opacity;
  349. };
  350. /**
  351. * @js NA
  352. * @lua NA
  353. */
  354. class CC_STUDIO_DLL ActionTintFrame:public ActionFrame
  355. {
  356. public:
  357. /**
  358. * Default constructor
  359. */
  360. ActionTintFrame();
  361. /**
  362. * Default destructor
  363. */
  364. virtual ~ActionTintFrame();
  365. /**
  366. * Changes the tint action color.
  367. *
  368. * @param ccolor the tint action color
  369. */
  370. void setColor(cocos2d::Color3B ccolor);
  371. /**
  372. * Gets the tint action color.
  373. *
  374. * @return the tint action color.
  375. */
  376. cocos2d::Color3B getColor();
  377. /**
  378. * Gets the ActionInterval of ActionFrame.
  379. *
  380. * @param duration the duration time of ActionFrame
  381. *
  382. * @return ActionInterval
  383. */
  384. virtual cocos2d::ActionInterval* getAction(float duration);
  385. protected:
  386. cocos2d::Color3B _color;
  387. };
  388. }
  389. #endif