1 添加了 按钮事件 Component
2 其他胜利条件 3 将 close 按钮封装 4 修改了 投骰子 和 UIRoot
This commit is contained in:
		
							parent
							
								
									71c9847d4f
								
							
						
					
					
						commit
						cb40c0a43c
					
				|  | @ -0,0 +1,55 @@ | ||||||
|  | import { _decorator, Component, EventMouse, Node } from 'cc'; | ||||||
|  | const { ccclass, property } = _decorator; | ||||||
|  | 
 | ||||||
|  | @ccclass('BaseButtonAction') | ||||||
|  | export class BaseButtonAction extends Component { | ||||||
|  | 
 | ||||||
|  |     onMouseUp?: Function; | ||||||
|  |     onMouseLeftUp?: Function; | ||||||
|  |     onMouseRightUp?: Function; | ||||||
|  | 
 | ||||||
|  |     onMouseDown?: Function; | ||||||
|  |     onMouseLeftDown?: Function; | ||||||
|  |     onMouseRightDown?: Function; | ||||||
|  | 
 | ||||||
|  |     start() { | ||||||
|  |         this.node.on(Node.EventType.MOUSE_UP,this._onMouseUp,this); | ||||||
|  |         this.node.on(Node.EventType.MOUSE_DOWN,this._onMouseDown,this); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     private _onMouseUp(event:EventMouse){ | ||||||
|  |         if (this.onMouseUp) this.onMouseUp(); | ||||||
|  | 
 | ||||||
|  |         switch (event.getButton()) { | ||||||
|  |             case EventMouse.BUTTON_LEFT: | ||||||
|  |                 if (this.onMouseLeftUp) this.onMouseLeftUp(); | ||||||
|  |                 break; | ||||||
|  |             case EventMouse.BUTTON_RIGHT: | ||||||
|  |                 if (this.onMouseRightUp) this.onMouseRightUp(); | ||||||
|  |                 break; | ||||||
|  |             default: | ||||||
|  |                 break; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     private _onMouseDown(event:EventMouse){ | ||||||
|  |         if (this.onMouseDown) this.onMouseDown(); | ||||||
|  | 
 | ||||||
|  |         switch (event.getButton()) { | ||||||
|  |             case EventMouse.BUTTON_LEFT: | ||||||
|  |                 if (this.onMouseLeftDown) this.onMouseLeftDown(); | ||||||
|  |                 break; | ||||||
|  |             case EventMouse.BUTTON_RIGHT: | ||||||
|  |                 if (this.onMouseRightDown) this.onMouseRightDown(); | ||||||
|  |                 break; | ||||||
|  |             default: | ||||||
|  |                 break; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     update(deltaTime: number) { | ||||||
|  |          | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | @ -0,0 +1,9 @@ | ||||||
|  | { | ||||||
|  |   "ver": "4.0.23", | ||||||
|  |   "importer": "typescript", | ||||||
|  |   "imported": true, | ||||||
|  |   "uuid": "297493e6-04d1-4d0f-a06b-0c8bd259ad71", | ||||||
|  |   "files": [], | ||||||
|  |   "subMetas": {}, | ||||||
|  |   "userData": {} | ||||||
|  | } | ||||||
|  | @ -1,15 +1,22 @@ | ||||||
| import { _decorator, Component, EventMouse, Node } from 'cc'; | import { _decorator, Component, EventMouse, EventTouch, Node, UITransform } from 'cc'; | ||||||
| import { BaseSprite } from '../GlobalScript/CommonComponent/BaseSprite'; | import { BaseSprite } from '../GlobalScript/CommonComponent/BaseSprite'; | ||||||
| import { NpkImage } from '../Tool/NPKImage'; | import { NpkImage } from '../Tool/NPKImage'; | ||||||
| import { BaseButton, BaseButtonState } from '../GlobalScript/CommonComponent/BaseButton'; | import { BaseButton, BaseButtonState } from '../GlobalScript/CommonComponent/BaseButton'; | ||||||
| const { ccclass, property } = _decorator; | import { BaseButtonAction } from '../GlobalScript/CommonComponent/BaseButtonAction'; | ||||||
|  | const { ccclass } = _decorator; | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
|  | /// 投骰子按钮的整个节点
 | ||||||
| @ccclass('DiceButtonNode') | @ccclass('DiceButtonNode') | ||||||
| export class DiceButtonNode extends Node { | export class DiceButtonNode extends Node { | ||||||
| 
 | 
 | ||||||
|     winButtonComponent: BaseButton; |     winButtonComponent: BaseButton; | ||||||
|     spaceButtonComponent: BaseButton; |     spaceButtonComponent: BaseButton; | ||||||
|      |      | ||||||
|  |     winButtonBlock: Function; | ||||||
|  |     spaceDownBlock: Function; | ||||||
|  |     spaceUpBlock: Function; | ||||||
|  | 
 | ||||||
|     constructor(){ |     constructor(){ | ||||||
|         super(); |         super(); | ||||||
| 
 | 
 | ||||||
|  | @ -20,6 +27,12 @@ export class DiceButtonNode extends Node { | ||||||
| 
 | 
 | ||||||
|         /// 其他获胜条件
 |         /// 其他获胜条件
 | ||||||
|         const winButtonNode = new Node(); |         const winButtonNode = new Node(); | ||||||
|  |         this.addChild(winButtonNode); | ||||||
|  |         winButtonNode.setPosition(20.5,-123); | ||||||
|  | 
 | ||||||
|  |         const winBa = winButtonNode.addComponent(BaseButtonAction); | ||||||
|  |         winBa.onMouseUp = this.winOnMouseUp.bind(this); | ||||||
|  |          | ||||||
|         this.winButtonComponent = winButtonNode.addComponent( BaseButton ); |         this.winButtonComponent = winButtonNode.addComponent( BaseButton ); | ||||||
|         this.winButtonComponent.ButtonState = BaseButtonState.Disable; |         this.winButtonComponent.ButtonState = BaseButtonState.Disable; | ||||||
|         this.winButtonComponent.ImgPath = NpkImage.ingame; |         this.winButtonComponent.ImgPath = NpkImage.ingame; | ||||||
|  | @ -28,12 +41,16 @@ export class DiceButtonNode extends Node { | ||||||
|         this.winButtonComponent.PressImgIndex = 60; |         this.winButtonComponent.PressImgIndex = 60; | ||||||
|         this.winButtonComponent.DisableImgIndex = 61; |         this.winButtonComponent.DisableImgIndex = 61; | ||||||
| 
 | 
 | ||||||
|         this.addChild(winButtonNode); |  | ||||||
|         winButtonNode.setPosition(20.5,-123); |  | ||||||
|         // winButtonNode.on(Node.EventType.MOUSE_UP,this.winOnTouchUp,this);
 |  | ||||||
|          |          | ||||||
|         /// space
 |         /// space
 | ||||||
|         const spaceButtonNode = new Node(); |         const spaceButtonNode = new Node(); | ||||||
|  |         this.addChild(spaceButtonNode); | ||||||
|  |         spaceButtonNode.setPosition(89,-57); | ||||||
|  | 
 | ||||||
|  |         const spaceBc = spaceButtonNode.addComponent( BaseButtonAction); | ||||||
|  |         spaceBc.onMouseLeftDown = this.spaceOnMouseDown.bind(this); | ||||||
|  |         spaceBc.onMouseLeftUp = this.spaceOnMouseUp.bind(this); | ||||||
|  | 
 | ||||||
|         this.spaceButtonComponent = spaceButtonNode.addComponent( BaseButton ); |         this.spaceButtonComponent = spaceButtonNode.addComponent( BaseButton ); | ||||||
|         this.spaceButtonComponent.ButtonState = BaseButtonState.Disable; |         this.spaceButtonComponent.ButtonState = BaseButtonState.Disable; | ||||||
|         this.spaceButtonComponent.ImgPath = NpkImage.ingame; |         this.spaceButtonComponent.ImgPath = NpkImage.ingame; | ||||||
|  | @ -42,27 +59,22 @@ export class DiceButtonNode extends Node { | ||||||
|         this.spaceButtonComponent.PressImgIndex = 10; |         this.spaceButtonComponent.PressImgIndex = 10; | ||||||
|         this.spaceButtonComponent.DisableImgIndex = 11; |         this.spaceButtonComponent.DisableImgIndex = 11; | ||||||
| 
 | 
 | ||||||
|         this.addChild(spaceButtonNode); |  | ||||||
|         spaceButtonNode.setPosition(89,-57); |  | ||||||
|         // spaceButtonNode.on(Node.EventType.MOUSE_DOWN,this.spaceOnTouchDown,this);
 |  | ||||||
|         // spaceButtonNode.on(Node.EventType.MOUSE_UP,this.spaceOnTouchUp,this);
 |  | ||||||
|          |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     winOnTouchUp(event:EventMouse){ |     /// 其他获胜条件
 | ||||||
|         if (event.getButton() != EventMouse.BUTTON_LEFT) return; |     private winOnMouseUp(event:EventMouse){ | ||||||
| 
 |         if (this.winButtonComponent.ButtonState == BaseButtonState.Disable ) return; | ||||||
|  |         if (this.winButtonBlock) this.winButtonBlock(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     spaceOnTouchDown(event:EventMouse){ |     /// 投骰子
 | ||||||
|         if (event.getButton() != EventMouse.BUTTON_LEFT) return; |     private spaceOnMouseDown(event:EventMouse){ | ||||||
| 
 |         if (this.spaceButtonComponent.ButtonState == BaseButtonState.Disable ) return; | ||||||
|  |         if (this.spaceDownBlock) this.spaceDownBlock(); | ||||||
|     } |     } | ||||||
|     spaceOnTouchUp(event:EventMouse){ |     private spaceOnMouseUp(event: EventMouse){ | ||||||
|         if (event.getButton() != EventMouse.BUTTON_LEFT) return; |         if (this.spaceButtonComponent.ButtonState == BaseButtonState.Disable ) return; | ||||||
| 
 |         if (this.spaceUpBlock) this.spaceUpBlock(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
|  |  | ||||||
|  | @ -0,0 +1,58 @@ | ||||||
|  | import { _decorator, BlockInputEvents, Component, Node, Size, UITransform, v2 } from 'cc'; | ||||||
|  | import { BaseSprite } from '../GlobalScript/CommonComponent/BaseSprite'; | ||||||
|  | import { NpkImage } from '../Tool/NPKImage'; | ||||||
|  | import { closeButtonNode } from './common/closeButtonNode'; | ||||||
|  | const { ccclass, property } = _decorator; | ||||||
|  | 
 | ||||||
|  | export enum otherWinType{ | ||||||
|  |     /// 长跑达人
 | ||||||
|  |     longRun = 0, | ||||||
|  |     /// 地轨中心的王
 | ||||||
|  |     groundKing = 1, | ||||||
|  |     /// 哈林的王
 | ||||||
|  |     halinKing = 2, | ||||||
|  |     /// 魔界大战的王
 | ||||||
|  |     hellWarKing = 3, | ||||||
|  |     /// 切斯特小镇的王
 | ||||||
|  |     townsKing = 4, | ||||||
|  |     /// 区域独占
 | ||||||
|  |     districtExclusive = 5 | ||||||
|  | 
 | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | /// 其他获胜条件
 | ||||||
|  | @ccclass('OtherWinNode') | ||||||
|  | export class OtherWinNode extends Node { | ||||||
|  |      | ||||||
|  |     constructor(type:otherWinType){ | ||||||
|  |         super(); | ||||||
|  | 
 | ||||||
|  |         this.setPosition(0,0); | ||||||
|  |         this.addComponent( UITransform).setContentSize(new Size(1067,600)); | ||||||
|  |         this.getComponent(UITransform).anchorPoint = v2(0, 1); | ||||||
|  |         this.addComponent( BlockInputEvents ); | ||||||
|  |          | ||||||
|  |         /// 获胜条件图片
 | ||||||
|  |         const winImgNode = new Node(); | ||||||
|  |         this.addChild(winImgNode); | ||||||
|  | 
 | ||||||
|  |         this.setPosition(366,-176.5); | ||||||
|  | 
 | ||||||
|  |         const winBs = winImgNode.addComponent( BaseSprite ); | ||||||
|  |         winBs.updateSpriteFrame(NpkImage.conditionsofvictory,type); | ||||||
|  |          | ||||||
|  | 
 | ||||||
|  |         /// 关闭按钮
 | ||||||
|  |         const closeNode = new closeButtonNode(()=>{ | ||||||
|  |             this.active = false; | ||||||
|  |         }); | ||||||
|  |         winImgNode.addChild(closeNode); | ||||||
|  | 
 | ||||||
|  |         closeNode.setPosition(310,-15); | ||||||
|  | 
 | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | @ -0,0 +1,9 @@ | ||||||
|  | { | ||||||
|  |   "ver": "4.0.23", | ||||||
|  |   "importer": "typescript", | ||||||
|  |   "imported": true, | ||||||
|  |   "uuid": "b5b4e31e-b152-4a72-968b-3aa98a6aaa77", | ||||||
|  |   "files": [], | ||||||
|  |   "subMetas": {}, | ||||||
|  |   "userData": {} | ||||||
|  | } | ||||||
|  | @ -5,6 +5,7 @@ import { BaseButton } from '../GlobalScript/CommonComponent/BaseButton'; | ||||||
| import { AnimationNode } from '../GlobalScript/Animation/AnimationNode'; | import { AnimationNode } from '../GlobalScript/Animation/AnimationNode'; | ||||||
| import { CharacterType, GamerNode } from './GamerNode'; | import { CharacterType, GamerNode } from './GamerNode'; | ||||||
| import { UIRoot } from './UIRoot'; | import { UIRoot } from './UIRoot'; | ||||||
|  | import {closeButtonNode } from './common/closeButtonNode'; | ||||||
| const { ccclass } = _decorator; | const { ccclass } = _decorator; | ||||||
| 
 | 
 | ||||||
| /// 开始游戏按钮界面
 | /// 开始游戏按钮界面
 | ||||||
|  | @ -118,14 +119,17 @@ export class StartGameUINode extends Node { | ||||||
|     initPressen(){ |     initPressen(){ | ||||||
|         /// 节点
 |         /// 节点
 | ||||||
|         this.pressenNode = new Node('Pressen'); |         this.pressenNode = new Node('Pressen'); | ||||||
|         this.pressenNode.setPosition(0,9999); |         this.pressenNode.active = false; | ||||||
|  |         this.addChild(this.pressenNode); | ||||||
|  | 
 | ||||||
|  |         this.pressenNode.setPosition(0,0); | ||||||
|         this.pressenNode.addComponent( UITransform).setContentSize(1067,600); |         this.pressenNode.addComponent( UITransform).setContentSize(1067,600); | ||||||
|         this.pressenNode.getComponent(UITransform).anchorPoint = v2(0, 1); |         this.pressenNode.getComponent(UITransform).anchorPoint = v2(0, 1); | ||||||
|          |          | ||||||
|         /// 拦截下层的点击事件
 |         /// 拦截下层的点击事件
 | ||||||
|         this.pressenNode.addComponent( BlockInputEvents ); |         this.pressenNode.addComponent( BlockInputEvents ); | ||||||
| 
 | 
 | ||||||
|         /// 给节点添加 img 节点
 |         /// 给节点添加 img 
 | ||||||
|         const imgNode = new Node('PressenImage'); |         const imgNode = new Node('PressenImage'); | ||||||
|         imgNode.setPosition(134,-21.5); |         imgNode.setPosition(134,-21.5); | ||||||
|         const imgComponent = imgNode.addComponent( BaseSprite ); |         const imgComponent = imgNode.addComponent( BaseSprite ); | ||||||
|  | @ -133,35 +137,22 @@ export class StartGameUINode extends Node { | ||||||
|         this.pressenNode.addChild(imgNode); |         this.pressenNode.addChild(imgNode); | ||||||
|          |          | ||||||
|         /// 关闭按钮
 |         /// 关闭按钮
 | ||||||
|         const closeButtonNode = new Node('closeButton'); |         const closeNode = new closeButtonNode(this.closeOnTouchEnd.bind(this)); | ||||||
|         closeButtonNode.setPosition(767,-10); |         closeNode.setPosition(767,-10); | ||||||
|         imgNode.addChild(closeButtonNode); |         imgNode.addChild(closeNode); | ||||||
|          |          | ||||||
|         /// 给节点添加 button 组件
 |  | ||||||
|         const buttonComponent = closeButtonNode.addComponent( BaseButton ); |  | ||||||
|         buttonComponent.ImgPath = NpkImage.ingame; |  | ||||||
|         buttonComponent.NormalImgIndex = 39; |  | ||||||
|         buttonComponent.HoverImgIndex = 40; |  | ||||||
|         buttonComponent.PressImgIndex = 41; |  | ||||||
|         buttonComponent.DisableImgIndex = 42; |  | ||||||
| 
 |  | ||||||
|         closeButtonNode.on(Node.EventType.MOUSE_UP,this.closeOnTouchEnd,this); |  | ||||||
| 
 |  | ||||||
|         this.addChild(this.pressenNode); |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /// 打开玩法介绍
 |     /// 打开玩法介绍
 | ||||||
|     pressenOnTouchEnd(event:EventMouse){ |     pressenOnTouchEnd(event:EventMouse){ | ||||||
|         if ( event.getButton() === EventMouse.BUTTON_LEFT ){ |         if ( event.getButton() === EventMouse.BUTTON_LEFT ){ | ||||||
|             this.pressenNode.setPosition(0,0); |             this.pressenNode.active = true; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /// 关闭玩法介绍
 |      | ||||||
|     closeOnTouchEnd(event:EventMouse){ |     closeOnTouchEnd(event:EventMouse){ | ||||||
|         if ( event.getButton() === EventMouse.BUTTON_LEFT ){ |         this.pressenNode.active = false; | ||||||
|             this.pressenNode.setPosition(0,9999); |  | ||||||
|         } |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /// 开始游戏
 |     /// 开始游戏
 | ||||||
|  |  | ||||||
|  | @ -6,6 +6,7 @@ import { NpkImage } from '../Tool/NPKImage'; | ||||||
| import { AnimationNode } from '../GlobalScript/Animation/AnimationNode'; | import { AnimationNode } from '../GlobalScript/Animation/AnimationNode'; | ||||||
| import { BaseButton, BaseButtonState } from '../GlobalScript/CommonComponent/BaseButton'; | import { BaseButton, BaseButtonState } from '../GlobalScript/CommonComponent/BaseButton'; | ||||||
| import { DiceButtonNode } from './DiceButtonNode'; | import { DiceButtonNode } from './DiceButtonNode'; | ||||||
|  | import { OtherWinNode, otherWinType } from './OtherWinNode'; | ||||||
| const { ccclass } = _decorator; | const { ccclass } = _decorator; | ||||||
| 
 | 
 | ||||||
| @ccclass('UIRoot') | @ccclass('UIRoot') | ||||||
|  | @ -21,6 +22,8 @@ export class UIRoot extends Component { | ||||||
|     private gamerThree: GamerNode; |     private gamerThree: GamerNode; | ||||||
|     /// 投骰子按钮
 |     /// 投骰子按钮
 | ||||||
|     private diceButton: DiceButtonNode; |     private diceButton: DiceButtonNode; | ||||||
|  |     /// 其他胜利条件
 | ||||||
|  |     private otherWinNode: OtherWinNode; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|     /// 初始化开始游戏界面的UI
 |     /// 初始化开始游戏界面的UI
 | ||||||
|  | @ -32,10 +35,14 @@ export class UIRoot extends Component { | ||||||
| 
 | 
 | ||||||
|     /// 初始化游戏界面UI
 |     /// 初始化游戏界面UI
 | ||||||
|     initGameUI(){ |     initGameUI(){ | ||||||
|         /// 初始化玩家UI
 |         /// 玩家UI
 | ||||||
|         this.initGamerUI(); |         this.initGamerUI(); | ||||||
|  |         /// 右下骰子操作按钮
 | ||||||
|         this.initDiceButton(); |         this.initDiceButton(); | ||||||
|  |         /// 等待玩家加载
 | ||||||
|         this.initAwaitGamerUI(); |         this.initAwaitGamerUI(); | ||||||
|  |         /// 其他胜利条件
 | ||||||
|  |         this.initOtherNode(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /// 初始化玩家UI
 |     /// 初始化玩家UI
 | ||||||
|  | @ -80,8 +87,10 @@ export class UIRoot extends Component { | ||||||
|               this.awaitGamerNode.destroy(); |               this.awaitGamerNode.destroy(); | ||||||
|             }); |             }); | ||||||
| 
 | 
 | ||||||
|  |             this.aniDone(); | ||||||
|  | 
 | ||||||
|             /// 初始化开始倒计时
 |             /// 初始化开始倒计时
 | ||||||
|             this.initCountFontAni(5); |             // this.initCountFontAni(5);
 | ||||||
| 
 | 
 | ||||||
|         },2); |         },2); | ||||||
|     } |     } | ||||||
|  | @ -95,7 +104,8 @@ export class UIRoot extends Component { | ||||||
|             if (index > 1){ |             if (index > 1){ | ||||||
|                 this.initCountFontAni(index-1); |                 this.initCountFontAni(index-1); | ||||||
|             }else{ |             }else{ | ||||||
|                 this.diceButton.winButtonComponent.ButtonState = BaseButtonState.Normal; |                 /// 动画结束
 | ||||||
|  |                 this.aniDone(); | ||||||
|             } |             } | ||||||
|         }); |         }); | ||||||
|         ani.setPosition(420,-180); |         ani.setPosition(420,-180); | ||||||
|  | @ -109,8 +119,30 @@ export class UIRoot extends Component { | ||||||
|         this.diceButton = new DiceButtonNode(); |         this.diceButton = new DiceButtonNode(); | ||||||
|         this.diceButton.setPosition(849,-453); |         this.diceButton.setPosition(849,-453); | ||||||
|         this.node.addChild(this.diceButton); |         this.node.addChild(this.diceButton); | ||||||
|  | 
 | ||||||
|  |         /// 显示其他胜利条件
 | ||||||
|  |         this.diceButton.winButtonBlock = ()=>{ | ||||||
|  |             this.otherWinNode.active = true; | ||||||
|  |         }; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     /// 初始化其他胜利条件
 | ||||||
|  |     initOtherNode(){ | ||||||
|  |         this.otherWinNode = new OtherWinNode(otherWinType.longRun); | ||||||
|  |         this.node.addChild(this.otherWinNode); | ||||||
|  | 
 | ||||||
|  |         this.otherWinNode.active = false; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |     aniDone(){ | ||||||
|  |         /// 恢复其他胜利按钮的状态
 | ||||||
|  |         this.diceButton.winButtonComponent.ButtonState = BaseButtonState.Normal; | ||||||
|  |         /// 显示其他胜利条件
 | ||||||
|  |         this.otherWinNode.active = true; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
|     start() { |     start() { | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -0,0 +1,9 @@ | ||||||
|  | { | ||||||
|  |   "ver": "1.2.0", | ||||||
|  |   "importer": "directory", | ||||||
|  |   "imported": true, | ||||||
|  |   "uuid": "d818878d-a3a8-44f6-b015-3baf1193c4b9", | ||||||
|  |   "files": [], | ||||||
|  |   "subMetas": {}, | ||||||
|  |   "userData": {} | ||||||
|  | } | ||||||
|  | @ -0,0 +1,29 @@ | ||||||
|  | import { _decorator, Component, Node } from 'cc'; | ||||||
|  | import { BaseButton } from '../../GlobalScript/CommonComponent/BaseButton'; | ||||||
|  | import { NpkImage } from '../../Tool/NPKImage'; | ||||||
|  | import { BaseButtonAction } from '../../GlobalScript/CommonComponent/BaseButtonAction'; | ||||||
|  | const { ccclass, property } = _decorator; | ||||||
|  | 
 | ||||||
|  | @ccclass('closeButtonNode') | ||||||
|  | export class closeButtonNode extends Node { | ||||||
|  | 
 | ||||||
|  |     constructor(onMouseLeftUp?:Function){ | ||||||
|  |         super(); | ||||||
|  | 
 | ||||||
|  |         /// 给节点添加 button 组件
 | ||||||
|  |         const buttonComponent = this.addComponent( BaseButton ); | ||||||
|  |         buttonComponent.ImgPath = NpkImage.ingame; | ||||||
|  |         buttonComponent.NormalImgIndex = 39; | ||||||
|  |         buttonComponent.HoverImgIndex = 40; | ||||||
|  |         buttonComponent.PressImgIndex = 41; | ||||||
|  |         buttonComponent.DisableImgIndex = 42; | ||||||
|  | 
 | ||||||
|  |         /// 添加点击事件
 | ||||||
|  |         const bba = this.addComponent( BaseButtonAction ); | ||||||
|  |         bba.onMouseLeftUp = onMouseLeftUp; | ||||||
|  | 
 | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | @ -0,0 +1,9 @@ | ||||||
|  | { | ||||||
|  |   "ver": "4.0.23", | ||||||
|  |   "importer": "typescript", | ||||||
|  |   "imported": true, | ||||||
|  |   "uuid": "9860c0fa-a57e-4bc5-9466-5d71cc5026ad", | ||||||
|  |   "files": [], | ||||||
|  |   "subMetas": {}, | ||||||
|  |   "userData": {} | ||||||
|  | } | ||||||
		Loading…
	
		Reference in New Issue