// 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 Ui extends cc.Component {
@property(cc.Label)
label: cc.Label = null;
@property
text: string = 'hello';
@property({
type: cc.Node
})
dialog: cc.Node = null;
@property({
type: cc.Button
})
btnScale: cc.Button = null;
@property({
type: cc.Button
})
btnMove: cc.Button = null;
scaleClickCount: number = 0;
moveClickCount: number = 0;
// LIFE-CYCLE CALLBACKS:
onl oad() {
let LEFT_TO_RIGHT: string = "letfToRight";
let SCALE_TO_SHOW: string = "scaleToShow";
this.dialog.active = false;
this.btnScale.node.on("click", (data) => {
this.dialog.active = true;
let anim: cc.Animation = this.dialog.getComponent(cc.Animation);
console.log("scal = ", this.scaleClickCount++, ", anim ", anim);
// anim && anim.playAdditive("letfToRight");
anim && anim.playAdditive(SCALE_TO_SHOW);
// anim && anim.play("scaleToShow");
}, this);
cc.Event.EventTouch
this.btnMove.node.on("click", (data) => {
this.dialog.active = true;
let dialog = this.node.getChildByName("dialog");
let anim: cc.Animation = dialog.getComponent(cc.Animation);
let state: cc.AnimationState = anim.getAnimationState(LEFT_TO_RIGHT);
// state.repeatCount = 5;
anim.on('lastframe', (msg) => {
console.log("anim lastframe");
}, this);
anim.on('stop', (msg) => {
console.log("anim stop ", msg);
}, this);
anim.on('play', (msg) => {
console.log("anim play ", msg);
}, this);
anim.on('resume', (msg) => {
console.log("anim resume ", msg);
}, this);
anim && anim.playAdditive(LEFT_TO_RIGHT);
console.log("move = ", state.repeatCount, ", ", this.moveClickCount++, ", anim = ", anim);
// anim && anim.play('leftToRight');
}, this);
}
start() {
}
// update (dt) {}
}