我智商爆棚
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/Platform/th/ScaleScripts.ts

48 lines
1.1 KiB

4 weeks ago
// Learn TypeScript:
// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
const {ccclass, property} = cc._decorator;
@ccclass
export default class ScaleScripts extends cc.Component {
@property(cc.Float)
scaleStart: number = 1;
@property(cc.Float)
scaleEnd: number = 1;
@property(cc.Float)
time: number = 0.2;
tw = null;
// LIFE-CYCLE CALLBACKS:
onLoad () {
this.startTween();
}
startTween () {
if (null == this.tw){
this.tw = cc.tween(this.node)
.repeatForever(
cc.tween()
.to(this.time, { scale: this.scaleEnd})
.to(this.time*1.5, { scale: this.scaleStart })
)
.start()
}
}
stop(){
if (this.tw !=null){
this.tw.stop();
this.node.scale = this.scaleStart;
this.tw = null;
}
}
// update (dt) {}
}