DaFuWeng/assets/Script/StartGameRoot.ts

42 lines
1.0 KiB
TypeScript

import { _decorator, Button, Component, EventTouch, instantiate, Node, Prefab } from 'cc';
const { ccclass, property } = _decorator;
@ccclass('StartGameRoot')
export class StartGameRoot extends Component {
/// 玩法介绍按钮
@property(Node) PressenButton: Node;
/// 玩法介绍UI预制件
@property(Prefab) pressenPrefab: Prefab;
//// 开始游戏按钮
@property(Node) StartButton: Node;
/// UI层预制件
@property(Prefab) UIPrefab: Prefab;
start() {
this.PressenButton.on(Node.EventType.TOUCH_END,this.pressenOnTouchEnd,this);
this.StartButton.on(Node.EventType.TOUCH_END,this.startOnTouchEnd,this);
}
pressenOnTouchEnd(event:Event){
const pressent = instantiate(this.pressenPrefab);
this.node.addChild(pressent);
pressent.setPosition(0,0);
}
startOnTouchEnd(event:Event){
this.node.destroy();
const ui = instantiate(this.UIPrefab);
this.node.parent.addChild(ui);
}
update(deltaTime: number) {
}
}