parent
							
								
									d94ea3f4a9
								
							
						
					
					
						commit
						b5158644d3
					
				|  | @ -53,6 +53,32 @@ export class BaseButton extends Component { | ||||||
|     //按钮状态
 |     //按钮状态
 | ||||||
|     ButtonState = BaseButtonState.Normal; // 0 普通 1悬停 2按下 8失效
 |     ButtonState = BaseButtonState.Normal; // 0 普通 1悬停 2按下 8失效
 | ||||||
| 
 | 
 | ||||||
|  |     /** | ||||||
|  |      * @description: BaseButton初始化设置 | ||||||
|  |      * @param {string} ImgPath: npk中的路径 | ||||||
|  |      * @param {number} NormalIndex: 普通 在npk.img 中的idnex 其他状态自动+1 | ||||||
|  |      */ | ||||||
|  |     init(ImgPath:string,NormalIndex:number): void; | ||||||
|  |     init(ImgPath:string,NormalIndex:number,HoverIndex:number,PressIndex:number,DisableIndex:number,auto:boolean): void; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * @description: BaseButton初始化设置 | ||||||
|  |      * @param {string} ImgPath: npk中的路径 | ||||||
|  |      * @param {number} NormalIndex: 普通 在npk.img 中的idnex | ||||||
|  |      * @param {number} HoverIndex: 悬停 | ||||||
|  |      * @param {number} PressIndex 按下 | ||||||
|  |      * @param {number} DisableIndex 失效 | ||||||
|  |      * @param {number} Disable 是否启用失效状态 | ||||||
|  |      * @return {*} | ||||||
|  |      */ | ||||||
|  |     init(ImgPath:string,NormalIndex:number,HoverIndex?:number,PressIndex?:number,DisableIndex?:number,Disable:boolean = true): void{ | ||||||
|  |         this.ImgPath = ImgPath; | ||||||
|  |         this.NormalImgIndex = NormalIndex; | ||||||
|  |         this.HoverImgIndex = HoverIndex ? HoverIndex : NormalIndex + 1; | ||||||
|  |         this.PressImgIndex = PressIndex ? PressIndex : NormalIndex + 2; | ||||||
|  |         if (Disable){ this.DisableImgIndex = DisableIndex ? DisableIndex : NormalIndex + 3; } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     start() { |     start() { | ||||||
| 
 | 
 | ||||||
|         //判断是否有精灵 如果没有 就给他搞一个
 |         //判断是否有精灵 如果没有 就给他搞一个
 | ||||||
|  |  | ||||||
|  | @ -60,11 +60,12 @@ export class StartGameUINode extends Node { | ||||||
| 
 | 
 | ||||||
|         /// 给节点添加 button 组件
 |         /// 给节点添加 button 组件
 | ||||||
|         const buttonComponent = startButtonNode.addComponent( BaseButton ); |         const buttonComponent = startButtonNode.addComponent( BaseButton ); | ||||||
|         buttonComponent.ImgPath = NpkImage.main; |         buttonComponent.init(NpkImage.main,1); | ||||||
|         buttonComponent.NormalImgIndex = 1; |         // buttonComponent.ImgPath = NpkImage.main;
 | ||||||
|         buttonComponent.HoverImgIndex = 2; |         // buttonComponent.NormalImgIndex = 1;
 | ||||||
|         buttonComponent.PressImgIndex = 3; |         // buttonComponent.HoverImgIndex = 2;
 | ||||||
|         buttonComponent.DisableImgIndex = 4; |         // buttonComponent.PressImgIndex = 3;
 | ||||||
|  |         // buttonComponent.DisableImgIndex = 4;
 | ||||||
| 
 | 
 | ||||||
|         startButtonNode.addComponent( Button) |         startButtonNode.addComponent( Button) | ||||||
|         startButtonNode.on(Button.EventType.CLICK,this.startOnTouchEnd,this); |         startButtonNode.on(Button.EventType.CLICK,this.startOnTouchEnd,this); | ||||||
|  | @ -93,11 +94,7 @@ export class StartGameUINode extends Node { | ||||||
| 
 | 
 | ||||||
|         /// 给节点添加 button 组件
 |         /// 给节点添加 button 组件
 | ||||||
|         const buttonComponent = pressenButtonNode.addComponent( BaseButton ); |         const buttonComponent = pressenButtonNode.addComponent( BaseButton ); | ||||||
|         buttonComponent.ImgPath = NpkImage.main; |         buttonComponent.init(NpkImage.main,9); | ||||||
|         buttonComponent.NormalImgIndex = 9; |  | ||||||
|         buttonComponent.HoverImgIndex = 10; |  | ||||||
|         buttonComponent.PressImgIndex = 11; |  | ||||||
|         buttonComponent.DisableImgIndex = 12; |  | ||||||
| 
 | 
 | ||||||
|         pressenButtonNode.on(Node.EventType.MOUSE_UP,this.pressenOnTouchEnd,this); |         pressenButtonNode.on(Node.EventType.MOUSE_UP,this.pressenOnTouchEnd,this); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1,3 +1,10 @@ | ||||||
|  | /* | ||||||
|  |  * @Author: WoNiu | ||||||
|  |  * @Date: 2024-03-13 12:19:50 | ||||||
|  |  * @LastEditTime: 2024-03-22 22:49:20 | ||||||
|  |  * @LastEditors: WoNiu | ||||||
|  |  * @Description: | ||||||
|  |  */ | ||||||
| import { _decorator, EventMouse, Node } from 'cc'; | import { _decorator, EventMouse, Node } from 'cc'; | ||||||
| import { BaseSprite } from '../../GlobalScript/CommonComponent/BaseSprite'; | import { BaseSprite } from '../../GlobalScript/CommonComponent/BaseSprite'; | ||||||
| import { NpkImage } from '../../Tool/NPKImage'; | import { NpkImage } from '../../Tool/NPKImage'; | ||||||
|  | @ -34,12 +41,7 @@ export class DiceButtonNode extends Node { | ||||||
|         winBa.onMouseUp = this.winOnMouseUp.bind(this); |         winBa.onMouseUp = this.winOnMouseUp.bind(this); | ||||||
| 
 | 
 | ||||||
|         this.winButtonComponent = winButtonNode.addComponent( BaseButton ); |         this.winButtonComponent = winButtonNode.addComponent( BaseButton ); | ||||||
|         this.winButtonComponent.ButtonState = BaseButtonState.Disable; |         this.winButtonComponent.init(NpkImage.ingame,60) | ||||||
|         this.winButtonComponent.ImgPath = NpkImage.ingame; |  | ||||||
|         this.winButtonComponent.NormalImgIndex = 60; |  | ||||||
|         this.winButtonComponent.HoverImgIndex = 61; |  | ||||||
|         this.winButtonComponent.PressImgIndex = 62; |  | ||||||
|         this.winButtonComponent.DisableImgIndex = 63; |  | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|         /// space
 |         /// space
 | ||||||
|  | @ -52,12 +54,8 @@ export class DiceButtonNode extends Node { | ||||||
|         spaceBc.onMouseLeftUp = this.spaceOnMouseUp.bind(this); |         spaceBc.onMouseLeftUp = this.spaceOnMouseUp.bind(this); | ||||||
| 
 | 
 | ||||||
|         this.spaceButtonComponent = spaceButtonNode.addComponent( BaseButton ); |         this.spaceButtonComponent = spaceButtonNode.addComponent( BaseButton ); | ||||||
|  |         this.spaceButtonComponent.init(NpkImage.ingame,8); | ||||||
|         this.spaceButtonComponent.ButtonState = BaseButtonState.Disable; |         this.spaceButtonComponent.ButtonState = BaseButtonState.Disable; | ||||||
|         this.spaceButtonComponent.ImgPath = NpkImage.ingame; |  | ||||||
|         this.spaceButtonComponent.NormalImgIndex = 8; |  | ||||||
|         this.spaceButtonComponent.HoverImgIndex = 9; |  | ||||||
|         this.spaceButtonComponent.PressImgIndex = 10; |  | ||||||
|         this.spaceButtonComponent.DisableImgIndex = 11; |  | ||||||
| 
 | 
 | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -12,11 +12,7 @@ export class CloseButtonNode extends Node { | ||||||
| 
 | 
 | ||||||
|         /// 给节点添加 button 组件
 |         /// 给节点添加 button 组件
 | ||||||
|         const buttonComponent = this.addComponent( BaseButton ); |         const buttonComponent = this.addComponent( BaseButton ); | ||||||
|         buttonComponent.ImgPath = NpkImage.ingame; |         buttonComponent.init(NpkImage.ingame,39); | ||||||
|         buttonComponent.NormalImgIndex = 39; |  | ||||||
|         buttonComponent.HoverImgIndex = 40; |  | ||||||
|         buttonComponent.PressImgIndex = 41; |  | ||||||
|         buttonComponent.DisableImgIndex = 42; |  | ||||||
| 
 | 
 | ||||||
|         /// 添加点击事件
 |         /// 添加点击事件
 | ||||||
|         const bba = this.addComponent( BaseButtonAction ); |         const bba = this.addComponent( BaseButtonAction ); | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue