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