Sun_moves/assets/Script/Sun.ts
2024-05-28 11:38:16 +08:00

95 lines
2.7 KiB
TypeScript

// 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;
import GameManager from './GameManager';
import { Notification } from './Notification';
@ccclass
export default class NewClass extends cc.Component {
id_Number:number
_speed:number
_color:number
touch:boolean
_repeat:boolean
move:boolean
// LIFE-CYCLE CALLBACKS:
// onLoad () {}
start () {
this.touch = true;
this.move = false;
this._color = 0;
this._speed = 0;
var shan = this.node.getChildByName("shan");
cc.tween(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();
}
init(_id,color,speed,repeat){
this.id_Number = _id;
this._color = color;
this._speed = speed;
this._repeat = repeat;
}
showNumber(type){
this.node.getChildByName("number").active = type;
if(type == true)
this.node.getChildByName("number").getComponent(cc.Label).string = this.id_Number + "";
}
clickBtn(){
var temp = this.node.parent.parent.name;
// console.log(temp,this.move,this.touch);
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;
Notification.emit("clickSun",this.id_Number);
}
}
else{
this.touch = false;
this.node.zIndex = -1;
Notification.emit("clickSun",this.id_Number);
}
}
}
clickBtn2(){
if( this.touch == true && this.node.parent.parent.getComponent("GuideManager").begin == true){
this.touch = false;
this.node.zIndex = -1;
Notification.emit("clickSun",this.id_Number);
}
}
update (dt) {
}
}