parent
							
								
									eeaeff06ce
								
							
						
					
					
						commit
						7d5a49862c
					
				|  | @ -185,6 +185,94 @@ class Yosin_EmeStretch extends Yosin_CommonUi { | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | //九宫格拉伸 | ||||||
|  | class Yosin_NineBoxStretch extends Yosin_CommonUi { | ||||||
|  | 
 | ||||||
|  |     constructor(X, Y, W, H, Path, Idx) { | ||||||
|  |         base.constructor(X, Y, W, H); | ||||||
|  |         DrawBackground( W, H, Path, Idx); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |     // 绘制 | ||||||
|  |     function DrawBackground(width, height, path, imgId) { | ||||||
|  | 
 | ||||||
|  |         local x = 0; | ||||||
|  |         local y = 0; | ||||||
|  | 
 | ||||||
|  |         // 左上角 | ||||||
|  |         local backgroundTopLeft = CL_SpriteObject(path, imgId); | ||||||
|  |         backgroundTopLeft.SetPosition(x, y); | ||||||
|  |         Addchild(backgroundTopLeft); | ||||||
|  |         // 左上角图片大小 | ||||||
|  |         local cornerImgSize = backgroundTopLeft.GetSize(); | ||||||
|  |         local cornerWidth = cornerImgSize.w; | ||||||
|  |         local cornerHeight = cornerImgSize.h; | ||||||
|  | 
 | ||||||
|  |         // 中间 | ||||||
|  |         local backgroundCenter = CL_SpriteObject(path, imgId + 4); | ||||||
|  |         backgroundCenter.SetPosition(cornerWidth, y + cornerHeight); | ||||||
|  |         Addchild(backgroundCenter); | ||||||
|  |         // 中间图片大小 | ||||||
|  |         local centerImgSize = backgroundCenter.GetSize(); | ||||||
|  |         local centerWidth = centerImgSize.w; | ||||||
|  |         local centerHeight = centerImgSize.h; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |         local scaleW = (width.tofloat() - cornerWidth.tofloat() * 2.0) / centerWidth.tofloat(); | ||||||
|  |         local scaleH = (height.tofloat() - y.tofloat() - cornerHeight.tofloat()) / centerHeight.tofloat(); | ||||||
|  | 
 | ||||||
|  |         // 上边 | ||||||
|  |         local backgroundTop = CL_SpriteObject(path, imgId + 1); | ||||||
|  |         backgroundTop.SetPosition(cornerWidth, y); | ||||||
|  |         backgroundTop.SetScale(scaleW, 1); | ||||||
|  |         Addchild(backgroundTop); | ||||||
|  | 
 | ||||||
|  |         // 右上角 | ||||||
|  |         local backgroundTopRight = CL_SpriteObject(path, imgId + 2); | ||||||
|  |         backgroundTopRight.SetPosition(width - cornerWidth, y); | ||||||
|  |         Addchild(backgroundTopRight); | ||||||
|  | 
 | ||||||
|  |         // 左边 | ||||||
|  |         local backgroundLeft = CL_SpriteObject(path, imgId + 3); | ||||||
|  |         backgroundLeft.SetPosition(x, y + cornerHeight ); | ||||||
|  |         backgroundLeft.SetScale(1, scaleH); | ||||||
|  |         Addchild(backgroundLeft); | ||||||
|  | 
 | ||||||
|  |         // 中间 | ||||||
|  |         backgroundCenter.SetScale(scaleW, scaleH); | ||||||
|  | 
 | ||||||
|  |         // 右边 | ||||||
|  |         local backgroundRight = CL_SpriteObject(path, imgId + 5); | ||||||
|  |         backgroundRight.SetPosition(width - cornerWidth, y + cornerHeight); | ||||||
|  |         backgroundRight.SetScale(1, scaleH); | ||||||
|  |         Addchild(backgroundRight); | ||||||
|  | 
 | ||||||
|  |         // 左下角 | ||||||
|  |         local backgroundBottomLeft = CL_SpriteObject(path, imgId + 6); | ||||||
|  |         backgroundBottomLeft.SetPosition(x, height - cornerHeight); | ||||||
|  |         Addchild(backgroundBottomLeft); | ||||||
|  | 
 | ||||||
|  |         // 下边 | ||||||
|  |         local backgroundBottom = CL_SpriteObject(path, imgId + 7); | ||||||
|  |         backgroundBottom.SetPosition(cornerWidth, height - cornerHeight); | ||||||
|  |         backgroundBottom.SetScale( scaleW , 1); | ||||||
|  |         Addchild(backgroundBottom); | ||||||
|  | 
 | ||||||
|  |         // 右下角 | ||||||
|  |         local backgroundBottomRight = CL_SpriteObject(path, imgId + 8); | ||||||
|  |         backgroundBottomRight.SetPosition(width - cornerWidth, height - cornerHeight); | ||||||
|  |         Addchild(backgroundBottomRight); | ||||||
|  | 
 | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| //拼接按钮 | //拼接按钮 | ||||||
| class Yosin_SplicingButton extends Yosin_CommonUi { | class Yosin_SplicingButton extends Yosin_CommonUi { | ||||||
|     //按钮状态 |     //按钮状态 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue