quick-tween.d.ts 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. declare module 'cc' {
  2. interface IPunchTweenOption extends ITweenOption {
  3. // How much the punch will vibrate
  4. vibrato?: number,
  5. // Represents how much (0 to 1) the vector will go beyond the starting position
  6. // when bouncing backwards. 1 creates a full oscillation between the punch direction and the
  7. // opposite direction, while 0 oscillates only between the punch and the start scale.
  8. elasticity?: number
  9. }
  10. interface IShakeTweenOption extends ITweenOption {
  11. vibrato?: number //每秒振动次数
  12. randomness?: number // 随机角度值
  13. fadeOut?: boolean // 是否淡出
  14. }
  15. interface Node {
  16. /**
  17. * @zh
  18. * 移动目标的坐标到指定位置
  19. * @en
  20. * Moves the target's position to the given value
  21. * @param to dest position
  22. * @param duration time in seconds
  23. * @param {ITweenOption} opts options for tween
  24. * @param {Function} opts.onStart start callback
  25. */
  26. qtPosition(to: Vec3, duration: number, opts?: ITweenOption): Tween<Node>;
  27. /**
  28. * @zh
  29. * 移动目标的坐标到指定位置, 只移动X坐标
  30. * @en
  31. * Moves the target's position to the given value, tweening only the X axis.
  32. * @param to dest position
  33. * @param duration time in seconds
  34. * @param opts options for tween
  35. */
  36. qtPositionX(to: number, duration: number, opts?: ITweenOption): Tween<Node>;
  37. /**
  38. * @zh
  39. * 移动目标的坐标到指定位置, 只移动Y坐标
  40. * @en
  41. * Moves the target's position to the given value, tweening only the Y axis.
  42. * @param to dest position
  43. * @param duration time in seconds
  44. * @param opts options for tween
  45. */
  46. qtPositionY(to: number, duration: number, opts?: ITweenOption): Tween<Node>;
  47. /**
  48. * @zh
  49. * 移动目标的坐标到指定位置, 只移动Z坐标
  50. * @en
  51. * Moves the target's position to the given value, tweening only the Z axis.
  52. * @param to dest position
  53. * @param duration time in seconds
  54. * @param opts options for tween
  55. */
  56. qtPositionZ(to: number, duration: number, opts?: ITweenOption): Tween<Node>;
  57. /**
  58. * @zh
  59. * 移动目标的世界坐标到指定位置
  60. * @en
  61. * Moves the target's worldPosition to the given value
  62. * @param to dest position
  63. * @param duration time in seconds
  64. * @param opts options for tween
  65. */
  66. qtWorldPosition(to: Vec3, duration: number, opts?: ITweenOption): Tween<Node>;
  67. /**
  68. * @zh
  69. * 移动目标的世界坐标到指定位置, 只移动X坐标
  70. * @en
  71. * Moves the target's worldPosition to the given value, tweening only the X axis.
  72. * @param to dest position
  73. * @param duration time in seconds
  74. * @param opts options for tween
  75. */
  76. qtWorldPositionX(to: number, duration: number, opts?: ITweenOption): Tween<Node>;
  77. /**
  78. * @zh
  79. * 移动目标的世界坐标到指定位置, 只移动Y坐标
  80. * @en
  81. * Moves the target's worldPosition to the given value, tweening only the Y axis.
  82. * @param to dest position
  83. * @param duration time in seconds
  84. * @param opts options for tween
  85. */
  86. qtWorldPositionY(to: number, duration: number, opts?: ITweenOption): Tween<Node>;
  87. /**
  88. * @zh
  89. * 移动目标的世界坐标到指定位置, 只移动Z坐标
  90. * @en
  91. * Moves the target's worldPosition to the given value, tweening only the Z axis.
  92. * @param to dest position
  93. * @param duration time in seconds
  94. * @param opts options for tween
  95. */
  96. qtWorldPositionZ(to: number, duration: number, opts?: ITweenOption): Tween<Node>;
  97. /**
  98. * @zh
  99. * 旋转目标到指定值
  100. * @en
  101. * Rotates the target to ghe given value
  102. * @param to dest rotation in eulerAngle
  103. * @param duration time in seconds
  104. * @param opts options for tween
  105. */
  106. qtRotation(to: Vec3, duration: number, opts?: ITweenOption): Tween<Node>;
  107. /**
  108. * @zh
  109. * 旋转目标到指定值
  110. * @en
  111. * Rotates the target to ghe given value
  112. * @param to dest rotation in quaternion
  113. * @param duration time in seconds
  114. * @param opts options for tween
  115. */
  116. qtRotationQuat(to: Quat, duration: number, opts?: ITweenOption): Tween<Node>;
  117. /**
  118. * @zh
  119. * 缩放目标到指定值
  120. * @en
  121. * Scales the target to ghe given value
  122. * @param to dest scale value
  123. * @param duration time in seconds
  124. * @param opts options for tween
  125. */
  126. qtScale(to: Vec3|number, duration: number, opts?: ITweenOption): Tween<Node>;
  127. /**
  128. * @zh
  129. * 缩放目标到指定值,只影响X轴
  130. * @en
  131. * Scales the target to ghe given value, tweening only X axis
  132. * @param to dest scale value
  133. * @param duration time in seconds
  134. * @param opts options for tween
  135. */
  136. qtScaleX(to: number, duration: number, opts?: ITweenOption): Tween<Node>;
  137. /**
  138. * @zh
  139. * 缩放目标到指定值,只影响Y轴
  140. * @en
  141. * Scales the target to ghe given value, tweening only Y axis
  142. * @param to dest scale value
  143. * @param duration time in seconds
  144. * @param opts options for tween
  145. */
  146. qtScaleY(to: number, duration: number, opts?: ITweenOption): Tween<Node>;
  147. /**
  148. * @zh
  149. * 缩放目标到指定值,只影响Z轴
  150. * @en
  151. * Scales the target to ghe given value, tweening only Z axis
  152. * @param to dest scale value
  153. * @param duration time in seconds
  154. * @param opts options for tween
  155. */
  156. qtScaleZ(to: number, duration: number, opts?: ITweenOption): Tween<Node>;
  157. /**
  158. * @zh
  159. * 击打目标位置到指定方向,然后回到初始值
  160. * @en
  161. * Punches a position towards the given direction and then
  162. * back to the starting one as if it was connected to the starting position
  163. * via an elastic.
  164. * @param punch The direction and strength of the punch, (added to the node's current position)
  165. * @param duration Time in seconds
  166. * @param {IPunchTweenOption} opts punch tween options
  167. * @param {number} opts.vibrato How much the punch will vibrate
  168. * @param {number} opts.elasticity Represents how much (0 to 1) the vector will go beyond the starting position
  169. * when bouncing backwards. 1 creates a full oscillation between the punch direction and the
  170. * opposite direction, while 0 oscillates only between the punch and the start position.
  171. */
  172. qtPunchPosition(punch: Vec3, duration: number, opts?: IPunchTweenOption): Tween<Node>;
  173. /**
  174. * @zh
  175. * 击打目标旋转方向到指定值,然后回到初始值
  176. * @en
  177. * Punches a rotation to the given value and then back to the starting one as if it was connected
  178. * to the starting rotation via an elastic.
  179. * @param punch The strength of punch, (added to the node's current rotation)
  180. * @param duration Time in seconds
  181. * @param {IPunchTweenOption} opts punch tween options
  182. * @param {number} opts.vibrato How much the punch will vibrate
  183. * @param {number} opts.elasticity Represents how much (0 to 1) the vector will go beyond the starting position
  184. * when bouncing backwards. 1 creates a full oscillation between the punch direction and the
  185. * opposite direction, while 0 oscillates only between the punch and the start rotation.
  186. */
  187. qtPunchRotation(punch: Vec3, duration: number, opts?: IPunchTweenOption): Tween<Node>;
  188. /**
  189. * @zh
  190. * 击打目标缩放到指定值,然后回到初始值
  191. * @en
  192. * Punches a scale to the given value and then back to the starting one as if it was connected
  193. * to the starting scale via an elastic.
  194. * @param punch The strength of punch, (added to the node's current scale)
  195. * @param duration Time in seconds
  196. * @param {IPunchTweenOption} opts punch tween options
  197. * @param {number} opts.vibrato How much the punch will vibrate
  198. * @param {number} opts.elasticity Represents how much (0 to 1) the vector will go beyond the starting position
  199. * when bouncing backwards. 1 creates a full oscillation between the punch direction and the
  200. * opposite direction, while 0 oscillates only between the punch and the start scale.
  201. */
  202. qtPunchScale(punch: Vec3, duration: number, opts?: IPunchTweenOption): Tween<Node>;
  203. jumpX?: number;
  204.         jumpY?: number;
  205.         jumpZ?: number;
  206.         jumpOffsetY?: number;
  207. /**
  208. * @zh
  209. * 缓动目标的坐标到指定值,在移动过程中同时附加一个Y坐标的高度值来模拟跳跃动作
  210. * @en
  211. * Tweens the target's position to the given value, while also applying a jump effect along the Y axis.
  212. * @param to 目标坐标值
  213. * @param jumpHeight 跳跃高度
  214. * @param jumpNum 跳跃次数
  215. * @param duration 时间
  216. * @param opts tween options
  217. */
  218. qtJumpPosition(to: Vec3, jumpHeight: number, jumpNum: number, duration: number, opts?: ITweenOption): Tween<Node>;
  219. /**
  220. * @zh
  221. * 使目标的位置在设定的参数下抖动
  222. * @en
  223. * Shakes the target's position with the given values
  224. * @param strength 强度
  225. * @param duration 时间
  226. * @param {IShakeTweenOption} opts shake tween options
  227. * @param {number} opts.vibrato 每秒振动次数
  228. * @param {number} opts.randomness 随机角度值
  229. * @param {boolean} opts.fadeOut 是否淡出
  230. */
  231. qtShakePosition(strength: Vec3|number, duration: number, opts?: IShakeTweenOption): Tween<Node>;
  232. /**
  233. * @zh
  234. * 使目标的旋转在设定的参数下抖动
  235. * @en
  236. * Shakes the target's rotation with the given values
  237. * @param strength 强度
  238. * @param duration 时间
  239. * @param {IShakeTweenOption} opts shake tween options
  240. * @param {number} opts.vibrato 每秒振动次数
  241. * @param {number} opts.randomness 随机角度值
  242. * @param {boolean} opts.fadeOut 是否淡出
  243. */
  244. qtShakeRotation(strength: Vec3|number, duration: number, opts?: IShakeTweenOption): Tween<Node>;
  245. /**
  246. * @zh
  247. * 使目标的缩放在设定的参数下抖动
  248. * @en
  249. * Shakes the target's scale with the given values
  250. * @param strength 强度
  251. * @param duration 时间
  252. * @param {IShakeTweenOption} opts shake tween options
  253. * @param {number} opts.vibrato 每秒振动次数
  254. * @param {number} opts.randomness 随机角度值
  255. * @param {boolean} opts.fadeOut 是否淡出
  256. */
  257. qtShakeScale(strength: Vec3|number, duration: number, opts?: IShakeTweenOption): Tween<Node>;
  258. }
  259. interface Sprite {
  260. qtColor(to: Color, duration: number, opts?: ITweenOption): Tween<Sprite>;
  261. qtOpacity(to: number, duration: number, opts?: ITweenOption): Tween<Sprite>;
  262. }
  263. interface Camera {
  264. /**
  265. * @zh
  266. * 使目标的位置在设定的参数下抖动
  267. * @en
  268. * Shakes the target's position with the given values
  269. * @param strength 强度
  270. * @param duration 时间
  271. * @param {IShakeTweenOption} opts shake tween options
  272. * @param {number} opts.vibrato 每秒振动次数
  273. * @param {number} opts.randomness 随机角度值
  274. * @param {boolean} opts.fadeOut 是否淡出
  275. */
  276. qtShakePosition(strength: Vec3|number, duration: number, opts?: IShakeTweenOption): Tween<Node>;
  277. }
  278. }