我智商爆棚
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.
 
 
 
 
 
wozhishangbaopeng/assets/WordGame/gameComScript/CirculateTweenAnimation.ts

53 lines
1.2 KiB

// Learn TypeScript:
// - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
// Learn Attribute:
// - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html
const { ccclass, property } = cc._decorator;
@ccclass
export default class CirculateTweenAnimation extends cc.Component {
@property(cc.Node)
circulateTweenNode: cc.Node = null;
@property(cc.Vec3)
startPoint: cc.Vec3 = null;
@property(cc.Vec3)
endPoint: cc.Vec3 = null;
@property()
time: number = 10;
// LIFE-CYCLE CALLBACKS:
// onLoad () {}
// start() {}
protected onEnable(): void {
if (!this.circulateTweenNode) {
this.circulateTweenNode = this.node;
}
let atween = cc.tween(this.circulateTweenNode)
.set({ position: this.startPoint })
.to(this.time, { position: this.endPoint })
.union()
.repeatForever()
.start();
this.node.attr({
stop: () => {
atween.stop();
}
});
}
// update (dt) {}
}