LikeLevelSubviewImpl.ts
1.61 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
import { DummyLabel, DummyNode, DummySprite } from "../../../../common/CCDummyObjects";
import { CCPureSubview } from "../../../../common/classbase/CCViewBase";
import { RegSubview } from "../../PresenterCCViewFactory";
import { LikeLevelProps, LikeLevelView, LikeLevelViewType } from "../type/LikeLevelSubview";
const { ccclass, property } = cc._decorator;
@ccclass
@RegSubview(LikeLevelViewType)
export class LikeLevelSubviewImpl extends CCPureSubview<LikeLevelProps> implements LikeLevelView {
//#region editor bindings
@property(cc.Sprite)
private bar = DummySprite;
@property(cc.Label)
private label = DummyLabel;
@property(cc.Node)
private graceNode = DummyNode;
likevalue: cc.Label = DummyLabel;
//#endregion
onLoad() {
super.onLoad();
this.likevalue = this.node.getChildByName("likevalue").getComponent(cc.Label);
this.bindProp("level", v => {
this.label.string = v + "";
});
this.bindProp("percent", v => {
this.bar.fillRange = v;
});
this.bindProp("visible", this.node, "active");
this.bindProp("like", (value) => {
if (value === "") {
this.likevalue.node.active = false;
} else {
this.likevalue.node.active = true;
this.likevalue.string = value;
}
});
}
onEnable() {
cc.tween(this.graceNode)
.repeatForever(cc.tween()
.to(0.8, { scale: 1.15 }, { easing: 'sineInOut' })
.to(0.8, { scale: 1 }, { easing: 'sineInOut' }))
.start();
}
}