|
@@ -6,7 +6,6 @@ const { ccclass, property } = cc._decorator;
|
|
|
*/
|
|
*/
|
|
|
@ccclass
|
|
@ccclass
|
|
|
export default class TweenUtil {
|
|
export default class TweenUtil {
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* 缩放效果
|
|
* 缩放效果
|
|
|
* @param node 动画节点
|
|
* @param node 动画节点
|
|
@@ -18,9 +17,7 @@ export default class TweenUtil {
|
|
|
public scale(node: cc.Node, time: number = 0.15, start_scale: number = 0, end_scale: number = 1, complete_fun?: Function) {
|
|
public scale(node: cc.Node, time: number = 0.15, start_scale: number = 0, end_scale: number = 1, complete_fun?: Function) {
|
|
|
node.scale = start_scale;
|
|
node.scale = start_scale;
|
|
|
let scale1 = cc.tween().to(time, { scale: end_scale });
|
|
let scale1 = cc.tween().to(time, { scale: end_scale });
|
|
|
- let call1 = cc.tween().call(() => {
|
|
|
|
|
- if (typeof complete_fun == 'function') complete_fun();
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ let call1 = cc.tween().call(() => { if (typeof complete_fun == 'function') complete_fun(); })
|
|
|
cc.tween(node).then(scale1).then(call1).start()
|
|
cc.tween(node).then(scale1).then(call1).start()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -35,9 +32,7 @@ export default class TweenUtil {
|
|
|
public scaleX(node: cc.Node, time: number = 0.15, start_scale: number = 0, end_scale: number = 1, complete_fun?: Function) {
|
|
public scaleX(node: cc.Node, time: number = 0.15, start_scale: number = 0, end_scale: number = 1, complete_fun?: Function) {
|
|
|
node.scaleX = start_scale;
|
|
node.scaleX = start_scale;
|
|
|
let scale1 = cc.tween().to(time, { scaleX: end_scale });
|
|
let scale1 = cc.tween().to(time, { scaleX: end_scale });
|
|
|
- let call1 = cc.tween().call(() => {
|
|
|
|
|
- if (typeof complete_fun == 'function') complete_fun();
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ let call1 = cc.tween().call(() => { if (typeof complete_fun == 'function') complete_fun(); })
|
|
|
cc.tween(node).then(scale1).then(call1).start()
|
|
cc.tween(node).then(scale1).then(call1).start()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -50,14 +45,73 @@ export default class TweenUtil {
|
|
|
* @param end_pos 结束节点位置
|
|
* @param end_pos 结束节点位置
|
|
|
* @param complete_fun 完成回调
|
|
* @param complete_fun 完成回调
|
|
|
*/
|
|
*/
|
|
|
- public scaleAndMove(node: cc.Node, time: number = 0.15, start_scale: number = 0, end_scale: number = 1, end_pos: cc.Vec2, complete_fun?: Function) {
|
|
|
|
|
|
|
+ public scaleParallelMove(node: cc.Node, time: number = 0.15, start_scale: number = 0, end_scale: number = 1, end_pos: cc.Vec2 = cc.Vec2.ZERO, complete_fun?: Function) {
|
|
|
node.scale = start_scale;
|
|
node.scale = start_scale;
|
|
|
let scale1 = cc.tween().to(time, { scale: end_scale });
|
|
let scale1 = cc.tween().to(time, { scale: end_scale });
|
|
|
let pos1 = cc.tween().to(time, { position: new cc.Vec3(end_pos.x, end_pos.y, 0) });
|
|
let pos1 = cc.tween().to(time, { position: new cc.Vec3(end_pos.x, end_pos.y, 0) });
|
|
|
- let call1 = cc.tween().call(() => {
|
|
|
|
|
- if (typeof complete_fun == 'function') complete_fun();
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ let call1 = cc.tween().call(() => { if (typeof complete_fun == 'function') complete_fun(); })
|
|
|
let parallel = cc.tween().parallel(scale1, pos1)
|
|
let parallel = cc.tween().parallel(scale1, pos1)
|
|
|
cc.tween(node).then(parallel).then(call1).start();
|
|
cc.tween(node).then(parallel).then(call1).start();
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 移动效果
|
|
|
|
|
+ * @param node
|
|
|
|
|
+ * @param time
|
|
|
|
|
+ * @param complete_fun
|
|
|
|
|
+ */
|
|
|
|
|
+ public move(node: cc.Node, time: number = 0.15, start_pos: cc.Vec2 = cc.Vec2.ZERO, end_pos: cc.Vec2 = cc.Vec2.ZERO, complete_fun?: Function, easing?: keyof typeof TweenEasing) {
|
|
|
|
|
+ node.setPosition(start_pos);
|
|
|
|
|
+ let pos1 = cc.tween().to(time, { position: new cc.Vec3(end_pos.x, end_pos.y, 0) }, { easing: easing });// cc.easeOut(3)
|
|
|
|
|
+ let call1 = cc.tween().call(() => { if (typeof complete_fun == 'function') complete_fun(); })
|
|
|
|
|
+ cc.tween(node).then(pos1).then(call1).start();
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
+/**
|
|
|
|
|
+ * 缓动类型
|
|
|
|
|
+ */
|
|
|
|
|
+enum TweenEasing {
|
|
|
|
|
+ linear,
|
|
|
|
|
+ smooth,
|
|
|
|
|
+ fade,
|
|
|
|
|
+ quadIn,
|
|
|
|
|
+ quadOut,
|
|
|
|
|
+ quadInOut,
|
|
|
|
|
+ quadOutIn,
|
|
|
|
|
+ cubicIn,
|
|
|
|
|
+ cubicOut,
|
|
|
|
|
+ cubicInOut,
|
|
|
|
|
+ cubicOutIn,
|
|
|
|
|
+ quartIn,
|
|
|
|
|
+ quartOut,
|
|
|
|
|
+ quartInOut,
|
|
|
|
|
+ quartOutIn,
|
|
|
|
|
+ quintIn,
|
|
|
|
|
+ quintOut,
|
|
|
|
|
+ quintInOut,
|
|
|
|
|
+ quintOutIn,
|
|
|
|
|
+ sineIn,
|
|
|
|
|
+ sineOut,
|
|
|
|
|
+ sineInOut,
|
|
|
|
|
+ sineOutIn,
|
|
|
|
|
+ expoIn,
|
|
|
|
|
+ expoOut,
|
|
|
|
|
+ expoInOut,
|
|
|
|
|
+ expoOutIn,
|
|
|
|
|
+ circIn,
|
|
|
|
|
+ circOut,
|
|
|
|
|
+ circInOut,
|
|
|
|
|
+ circOutIn,
|
|
|
|
|
+ elasticIn,
|
|
|
|
|
+ elasticOut,
|
|
|
|
|
+ elasticInOut,
|
|
|
|
|
+ elasticOutIn,
|
|
|
|
|
+ backIn,
|
|
|
|
|
+ backOut,
|
|
|
|
|
+ backInOut,
|
|
|
|
|
+ backOutIn,
|
|
|
|
|
+ bounceIn,
|
|
|
|
|
+ bounceOut,
|
|
|
|
|
+ bounceInOut,
|
|
|
|
|
+ bounceOutIn
|
|
|
|
|
+}
|