ScaleDisplayAction.ts
900 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
const { ccclass, property } = cc._decorator;
@ccclass
export default class ScaleDisplayAction extends cc.Component {
@property
speed: number = 1;
@property
scaleXMax: number = 1;
@property
scaleXMin: number = 0;
@property
scaleYMax: number = 1;
@property
scaleYMin: number = 0;
private readonly _baseTime: number = 1;
onLoad() { }
start() {
}
onEnable() {
this.node.scaleX = this.scaleXMin;
this.node.scaleY = this.scaleYMin;
let actTime: number = this._baseTime / this.speed;
let scaleAct = cc.scaleTo(actTime, this.scaleXMax, this.scaleYMax);
this.node.stopAllActions();
this.node.runAction(scaleAct.easing(cc.easeSineOut()));
}
onDisable() {
this.node.stopAllActions();
this.node.scaleX = this.scaleXMin;
this.node.scaleY = this.scaleYMin;
}
}