ScaleAction.ts
828 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
const { ccclass, property } = cc._decorator;
@ccclass
export default class ScaleAction extends cc.Component {
@property
speed: number = 1;
@property
scaleMax: number = 2;
@property
scaleMin: number = 0;
@property
defalutScale: number = 1;
private readonly _baseTime: number = 1;
onLoad() { }
start() {
}
onEnable() {
this.node.scale = this.defalutScale;
let actTime: number = this._baseTime / this.speed;
let maxAct = cc.scaleTo(actTime, this.scaleMax);
let minAct = cc.scaleTo(actTime, this.scaleMin);
this.node.stopAllActions();
this.node.runAction(cc.repeatForever(cc.sequence(maxAct, minAct)));
}
onDisable() {
this.node.stopAllActions();
this.node.scale = 1;
}
update(dt) { }
}