CCTweenFunction.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. /****************************************************************************
  2. Copyright (c) 2013-2016 Chukong Technologies Inc.
  3. Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
  4. http://www.cocos2d-x.org
  5. Permission is hereby granted, free of charge, to any person obtaining a copy
  6. of this software and associated documentation files (the "Software"), to deal
  7. in the Software without restriction, including without limitation the rights
  8. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. copies of the Software, and to permit persons to whom the Software is
  10. furnished to do so, subject to the following conditions:
  11. The above copyright notice and this permission notice shall be included in
  12. all copies or substantial portions of the Software.
  13. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19. THE SOFTWARE.
  20. ****************************************************************************/
  21. #ifndef __CCTWEENFUNCTION_H__
  22. #define __CCTWEENFUNCTION_H__
  23. /// @cond DO_NOT_SHOW
  24. #include "platform/CCPlatformMacros.h"
  25. NS_CC_BEGIN
  26. namespace tweenfunc {
  27. enum TweenType
  28. {
  29. CUSTOM_EASING = -1,
  30. Linear,
  31. Sine_EaseIn,
  32. Sine_EaseOut,
  33. Sine_EaseInOut,
  34. Quad_EaseIn,
  35. Quad_EaseOut,
  36. Quad_EaseInOut,
  37. Cubic_EaseIn,
  38. Cubic_EaseOut,
  39. Cubic_EaseInOut,
  40. Quart_EaseIn,
  41. Quart_EaseOut,
  42. Quart_EaseInOut,
  43. Quint_EaseIn,
  44. Quint_EaseOut,
  45. Quint_EaseInOut,
  46. Expo_EaseIn,
  47. Expo_EaseOut,
  48. Expo_EaseInOut,
  49. Circ_EaseIn,
  50. Circ_EaseOut,
  51. Circ_EaseInOut,
  52. Elastic_EaseIn,
  53. Elastic_EaseOut,
  54. Elastic_EaseInOut,
  55. Back_EaseIn,
  56. Back_EaseOut,
  57. Back_EaseInOut,
  58. Bounce_EaseIn,
  59. Bounce_EaseOut,
  60. Bounce_EaseInOut,
  61. TWEEN_EASING_MAX = 10000
  62. };
  63. //tween functions for CCActionEase
  64. /**
  65. * @param time in seconds.
  66. */
  67. float CC_DLL easeIn(float time, float rate);
  68. /**
  69. * @param time in seconds.
  70. */
  71. float CC_DLL easeOut(float time, float rate);
  72. /**
  73. * @param time in seconds.
  74. */
  75. float CC_DLL easeInOut(float time, float rate);
  76. /**
  77. * @param time in seconds.
  78. */
  79. float CC_DLL bezieratFunction( float a, float b, float c, float d, float t );
  80. /**
  81. * @param time in seconds.
  82. */
  83. float CC_DLL quadraticIn(float time);
  84. /**
  85. * @param time in seconds.
  86. */
  87. float CC_DLL quadraticOut(float time);
  88. /**
  89. * @param time in seconds.
  90. */
  91. float CC_DLL quadraticInOut(float time);
  92. /**
  93. * @param time in seconds.
  94. */
  95. float CC_DLL quadraticInOut(float time);
  96. /**
  97. * @param time in seconds.
  98. */
  99. float CC_DLL tweenTo(float time, TweenType type, float *easingParam);
  100. /**
  101. * @param time in seconds.
  102. */
  103. float CC_DLL linear(float time);
  104. /**
  105. * @param time in seconds.
  106. */
  107. float CC_DLL sineEaseIn(float time);
  108. /**
  109. * @param time in seconds.
  110. */
  111. float CC_DLL sineEaseOut(float time);
  112. /**
  113. * @param time in seconds.
  114. */
  115. float CC_DLL sineEaseInOut(float time);
  116. /**
  117. * @param time in seconds.
  118. */
  119. float CC_DLL quadEaseIn(float time);
  120. /**
  121. * @param time in seconds.
  122. */
  123. float CC_DLL quadEaseOut(float time);
  124. /**
  125. * @param time in seconds.
  126. */
  127. float CC_DLL quadEaseInOut(float time);
  128. /**
  129. * @param time in seconds.
  130. */
  131. float CC_DLL cubicEaseIn(float time);
  132. /**
  133. * @param time in seconds.
  134. */
  135. float CC_DLL cubicEaseOut(float time);
  136. /**
  137. * @param time in seconds.
  138. */
  139. float CC_DLL cubicEaseInOut(float time);
  140. /**
  141. * @param time in seconds.
  142. */
  143. float CC_DLL quartEaseIn(float time);
  144. /**
  145. * @param time in seconds.
  146. */
  147. float CC_DLL quartEaseOut(float time);
  148. /**
  149. * @param time in seconds.
  150. */
  151. float CC_DLL quartEaseInOut(float time);
  152. /**
  153. * @param time in seconds.
  154. */
  155. float CC_DLL quintEaseIn(float time);
  156. /**
  157. * @param time in seconds.
  158. */
  159. float CC_DLL quintEaseOut(float time);
  160. /**
  161. @param time in seconds.
  162. */
  163. float CC_DLL quintEaseInOut(float time);
  164. /**
  165. * @param time in seconds.
  166. */
  167. float CC_DLL expoEaseIn(float time);
  168. /**
  169. @param time in seconds.
  170. */
  171. float CC_DLL expoEaseOut(float time);
  172. /**
  173. * @param time in seconds.
  174. */
  175. float CC_DLL expoEaseInOut(float time);
  176. /**
  177. * @param time in seconds.
  178. */
  179. float CC_DLL circEaseIn(float time);
  180. /**
  181. * @param time in seconds.
  182. */
  183. float CC_DLL circEaseOut(float time);
  184. /**
  185. * @param time in seconds.
  186. */
  187. float CC_DLL circEaseInOut(float time);
  188. /**
  189. * @param time in seconds.
  190. * @param period in seconds.
  191. */
  192. float CC_DLL elasticEaseIn(float time, float period);
  193. /**
  194. * @param time in seconds.
  195. * @param period in seconds.
  196. */
  197. float CC_DLL elasticEaseOut(float time, float period);
  198. /**
  199. * @param time in seconds.
  200. * @param period in seconds.
  201. */
  202. float CC_DLL elasticEaseInOut(float time, float period);
  203. /**
  204. * @param time in seconds.
  205. */
  206. float CC_DLL backEaseIn(float time);
  207. /**
  208. * @param time in seconds.
  209. */
  210. float CC_DLL backEaseOut(float time);
  211. /**
  212. * @param time in seconds.
  213. */
  214. float CC_DLL backEaseInOut(float time);
  215. /**
  216. * @param time in seconds.
  217. */
  218. float CC_DLL bounceEaseIn(float time);
  219. /**
  220. * @param time in seconds.
  221. */
  222. float CC_DLL bounceEaseOut(float time);
  223. /**
  224. * @param time in seconds.
  225. */
  226. float CC_DLL bounceEaseInOut(float time);
  227. /**
  228. * @param time in seconds.
  229. */
  230. float CC_DLL customEase(float time, float *easingParam);
  231. }
  232. NS_CC_END
  233. /// @endcond
  234. #endif /*__CCTWEENFUNCTION_H__*/