添加UI子对象BUG修复 新增 三分图拉伸UI控件
This commit is contained in:
		
							parent
							
								
									46aeb7c8db
								
							
						
					
					
						commit
						c814502a74
					
				
							
								
								
									
										
											BIN
										
									
								
								Yosin_Engine.exe
								
								
								
								
							
							
						
						
									
										
											BIN
										
									
								
								Yosin_Engine.exe
								
								
								
								
							
										
											Binary file not shown.
										
									
								
							|  | @ -103,12 +103,12 @@ class Yosin_BaseWindow extends Layer { | ||||||
|     } |     } | ||||||
|     //设置回调事件 |     //设置回调事件 | ||||||
|     function SetUpdateFunc(Func) { |     function SetUpdateFunc(Func) { | ||||||
|         CallBackFunc = Func; |         UpdateFunc = Func; | ||||||
|     } |     } | ||||||
|     //逻辑 |     //逻辑 | ||||||
|     function Proc(Dt) { |     function Proc(Dt) { | ||||||
|         foreach(Window in UI_Childrens) { |         foreach(Window in UI_Childrens) { | ||||||
|             // if (Window.CallBackFunc) Window.CallBackFunc(Window); |             if (Window.UpdateFunc) Window.UpdateFunc(Window, Dt); | ||||||
|             Window.Proc(Dt); |             Window.Proc(Dt); | ||||||
|         } |         } | ||||||
|         //显示才调用Update |         //显示才调用Update | ||||||
|  | @ -125,6 +125,16 @@ class Yosin_BaseWindow extends Layer { | ||||||
|         Visible = Flag; |         Visible = Flag; | ||||||
|         base.SetVisible(Flag); |         base.SetVisible(Flag); | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|  |     /* | ||||||
|  |      * @函数作用: 添加子对象 | ||||||
|  |      * @参数 name | ||||||
|  |      */ | ||||||
|  |     function AddUIChild(gChild) { | ||||||
|  |         this.UI_Childrens.append(gChild); | ||||||
|  |         Addchild(gChild); | ||||||
|  |         // gChild.Parent = this; | ||||||
|  |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | @ -224,16 +234,6 @@ class Yosin_Window extends Yosin_BaseWindow { | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /* |  | ||||||
|      * @函数作用: 添加子对象 |  | ||||||
|      * @参数 name |  | ||||||
|      */ |  | ||||||
|     function AddUIChild(gChild) { |  | ||||||
|         this.UI_Childrens.append(gChild); |  | ||||||
|         Addchild(gChild); |  | ||||||
|         // gChild.Parent = this; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     //关闭窗口 -并没有销毁只是隐藏 |     //关闭窗口 -并没有销毁只是隐藏 | ||||||
|     function CloseWindow() { |     function CloseWindow() { | ||||||
|         this.Visible = false; |         this.Visible = false; | ||||||
|  |  | ||||||
|  | @ -41,6 +41,7 @@ class Yosin_CommonUi extends Yosin_BaseWindow { | ||||||
|         local Pos = GetWorldPosition(); |         local Pos = GetWorldPosition(); | ||||||
|         if (Math.IsIntersectRect(MousePos_X, MousePos_Y, 1, 1, Pos.x, Pos.y, Width, Height)) isInRect = true; |         if (Math.IsIntersectRect(MousePos_X, MousePos_Y, 1, 1, Pos.x, Pos.y, Width, Height)) isInRect = true; | ||||||
|         else isInRect = false; |         else isInRect = false; | ||||||
|  |         base.OnMouseProc(MousePos_X, MousePos_Y); | ||||||
|     } |     } | ||||||
|     //鼠标左键按下回调 |     //鼠标左键按下回调 | ||||||
|     function OnMouseLbDown(MousePos_X, MousePos_Y) { |     function OnMouseLbDown(MousePos_X, MousePos_Y) { | ||||||
|  | @ -52,10 +53,12 @@ class Yosin_CommonUi extends Yosin_BaseWindow { | ||||||
|                 Sq_PlaySoundEffect(OnClickSound); |                 Sq_PlaySoundEffect(OnClickSound); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |         base.OnMouseLbDown(MousePos_X, MousePos_Y); | ||||||
|     } |     } | ||||||
|     //鼠标左键弹起回调 |     //鼠标左键弹起回调 | ||||||
|     function OnMouseLbUp(MousePos_X, MousePos_Y) { |     function OnMouseLbUp(MousePos_X, MousePos_Y) { | ||||||
|         isLBDown = false; |         isLBDown = false; | ||||||
|  |         base.OnMouseLbUp(MousePos_X, MousePos_Y); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     //鼠标左键单击回调 |     //鼠标左键单击回调 | ||||||
|  | @ -64,6 +67,7 @@ class Yosin_CommonUi extends Yosin_BaseWindow { | ||||||
|         if (Math.IsIntersectRect(MousePos_X, MousePos_Y, 1, 1, Pos.x, Pos.y, Width, Height)) { |         if (Math.IsIntersectRect(MousePos_X, MousePos_Y, 1, 1, Pos.x, Pos.y, Width, Height)) { | ||||||
|             if (OnClick) OnClick(this); |             if (OnClick) OnClick(this); | ||||||
|         } |         } | ||||||
|  |         base.OnMouseLbClick(MousePos_X, MousePos_Y); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  | @ -72,7 +76,6 @@ class Yosin_CommonUi extends Yosin_BaseWindow { | ||||||
| class Yosin_BaseButton extends Yosin_CommonUi { | class Yosin_BaseButton extends Yosin_CommonUi { | ||||||
|     //按钮状态 |     //按钮状态 | ||||||
|     State = 0; |     State = 0; | ||||||
|     DWidth = null; |  | ||||||
|     Path = null; |     Path = null; | ||||||
|     Idx = null; |     Idx = null; | ||||||
| 
 | 
 | ||||||
|  | @ -82,7 +85,6 @@ class Yosin_BaseButton extends Yosin_CommonUi { | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|     constructor(X, Y, W, H, Path, Idx) { |     constructor(X, Y, W, H, Path, Idx) { | ||||||
|         this.DWidth = W; |  | ||||||
|         this.Path = Path; |         this.Path = Path; | ||||||
|         this.Idx = Idx; |         this.Idx = Idx; | ||||||
|         base.constructor(X, Y, W, H); |         base.constructor(X, Y, W, H); | ||||||
|  | @ -136,3 +138,45 @@ class Yosin_BaseButton extends Yosin_CommonUi { | ||||||
|         ChangeFrame(); |         ChangeFrame(); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | //三分法拉伸 | ||||||
|  | class Yosin_EmeStretch extends Yosin_CommonUi { | ||||||
|  | 
 | ||||||
|  |     Path = null; | ||||||
|  |     Idx = null; | ||||||
|  |     //按钮状态 | ||||||
|  |     SpriteList = null; | ||||||
|  | 
 | ||||||
|  |     constructor(X, Y, W, H, Path, Idx, Direction = true) { | ||||||
|  |         this.Path = Path; | ||||||
|  |         this.Idx = Idx; | ||||||
|  |         base.constructor(X, Y, W, H); | ||||||
|  | 
 | ||||||
|  |         SpriteList = []; | ||||||
|  |         SpriteList.push(CL_SpriteObject(Path, Idx)); | ||||||
|  |         SpriteList.push(CL_SpriteObject(Path, Idx + 1)); | ||||||
|  |         SpriteList.push(CL_SpriteObject(Path, Idx + 2)); | ||||||
|  | 
 | ||||||
|  |         //横向 | ||||||
|  |         if (Direction) { | ||||||
|  |             local ScaleW = (W - SpriteList[0].GetSize().w - SpriteList[2].GetSize().w); | ||||||
|  |             local ScaleRate = ScaleW / SpriteList[1].GetSize().w; | ||||||
|  |             SpriteList[1].SetPosition(SpriteList[0].GetSize().w, 0); | ||||||
|  |             SpriteList[1].SetScale(ScaleRate, 1.0); | ||||||
|  |             SpriteList[2].SetPosition(SpriteList[0].GetSize().w + ScaleW, 0); | ||||||
|  |         } | ||||||
|  |         //纵向 | ||||||
|  |         else { | ||||||
|  |             local ScaleH = (H - SpriteList[0].GetSize().h - SpriteList[2].GetSize().h); | ||||||
|  |             local ScaleRate = ScaleH / SpriteList[1].GetSize().h; | ||||||
|  |             SpriteList[1].SetPosition(0, SpriteList[0].GetSize().h); | ||||||
|  |             SpriteList[1].SetScale(1.0, ScaleRate); | ||||||
|  |             SpriteList[2].SetPosition(0, SpriteList[0].GetSize().h + ScaleH); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         foreach(Child in SpriteList) { | ||||||
|  |             Addchild(Child); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | @ -61,6 +61,8 @@ sqr/User/Stage/LodingStage.nut | ||||||
| sqr/User/Stage/TestStage.nut | sqr/User/Stage/TestStage.nut | ||||||
| 
 | 
 | ||||||
| sqr/User/UI/Widget/InputBox.nut | sqr/User/UI/Widget/InputBox.nut | ||||||
|  | sqr/User/UI/Widget/Drag_Button.nut | ||||||
|  | sqr/User/UI/Widget/Scroll_Bar.nut | ||||||
| 
 | 
 | ||||||
| sqr/User/UI/Window/0_Login.nut | sqr/User/UI/Window/0_Login.nut | ||||||
| sqr/User/UI/Window/1_Select_Character.nut | sqr/User/UI/Window/1_Select_Character.nut | ||||||
|  |  | ||||||
|  | @ -160,5 +160,14 @@ | ||||||
|     }, |     }, | ||||||
|     "Core/BaseClass/LayerObject.nut": { |     "Core/BaseClass/LayerObject.nut": { | ||||||
|         "description": "图层类" |         "description": "图层类" | ||||||
|  |     }, | ||||||
|  |     "User/UI/Widget/Scroll_Bar.nut": { | ||||||
|  |         "description": "滚动条" | ||||||
|  |     }, | ||||||
|  |     "User/UI/Widget/InputBox.nut": { | ||||||
|  |         "description": "输入框" | ||||||
|  |     }, | ||||||
|  |     "User/UI/Widget/Drag_Button.nut": { | ||||||
|  |         "description": "拖动按钮" | ||||||
|     } |     } | ||||||
| } | } | ||||||
		Loading…
	
		Reference in New Issue