const {ccclass, property} = cc._decorator; import { Notifications } from './module/Notification/Notification'; @ccclass export default class NewClass extends cc.Component { id_Number:number _speed:number _color:number touch:boolean _repeat:boolean move:boolean // onLoad () {} start () { } //初始化数据 init(_id,color,speed,repeat){ this.touch = true; this.move = false; this.id_Number = _id; this._color = color; this._speed = speed; this._repeat = repeat; //太阳动画 cc.tween(this.node.getChildByName("shan")) .repeatForever( cc.tween() .to(1,{opacity:0,scale:0.5,}) .delay(0.2) .to(1,{opacity:255,scale:1.2}) .delay(0.5) ) .start(); } //用于作弊 测试 showNumber(type){ this.node.getChildByName("number").active = type; if(type == true) this.node.getChildByName("number").getComponent(cc.Label).string = this.id_Number + ""; } //点击事件 clickBtn(event,data){ if(data === "1"){ if( this.move == false && this.touch == true){ if(this.node.parent.parent.name == "GameNode"){ if(this.node.parent.parent.getComponent("GameManager").begin == true){ cc.tween(this.node.getChildByName("action")) .to(0.5,{opacity:0,scale:1.8}) .start(); cc.tween(this.node) .to(0.3,{scale:1.3}) .to(0.3,{scale:1}) .start(); this.touch = false; this.node.zIndex = -1; Notifications.emit("clickSun",this.id_Number); } } else{ this.touch = false; this.node.zIndex = -1; Notifications.emit("clickSun",this.id_Number); } } } else{ if( this.touch == true && this.node.parent.parent.getComponent("GuideManager").begin == true){ this.touch = false; this.node.zIndex = -1; Notifications.emit("clickSun",this.id_Number); } } } }