27 lines
		
	
	
		
			617 B
		
	
	
	
		
			TypeScript
		
	
	
	
			
		
		
	
	
			27 lines
		
	
	
		
			617 B
		
	
	
	
		
			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;
 | |
| 
 | |
|     @property(Prefab) pressenPrefab: Prefab;
 | |
|     
 | |
|     start() {
 | |
|         this.PressenButton.on(Node.EventType.TOUCH_END,this.onTouchEnd,this);
 | |
|     }
 | |
| 
 | |
|     onTouchEnd(event:Event){
 | |
|         const pressent = instantiate(this.pressenPrefab);
 | |
|         this.node.addChild(pressent);
 | |
|         pressent.setPosition(0,0);
 | |
|     }
 | |
| 
 | |
|     update(deltaTime: number) {
 | |
|         
 | |
|     }
 | |
| }
 | |
| 
 | |
| 
 |