|
|
|
|
@ -142,24 +142,81 @@ class Yosin_BaseButton extends Yosin_CommonUi {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//三分法拉伸
|
|
|
|
|
class Yosin_EmeStretch extends Yosin_CommonUi {
|
|
|
|
|
// 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);
|
|
|
|
|
|
|
|
|
|
// // 创建画布
|
|
|
|
|
// local Canvas = CL_CanvasObject();
|
|
|
|
|
// // 重设大小并清空
|
|
|
|
|
// Canvas.ResizeAndClear(W, H);
|
|
|
|
|
// // 开始绘制
|
|
|
|
|
// Canvas.BeginDraw();
|
|
|
|
|
|
|
|
|
|
// 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.0);
|
|
|
|
|
// SpriteList[1].SetScale(ScaleRate, 1.0);
|
|
|
|
|
// SpriteList[2].SetPosition(SpriteList[0].GetSize().w + ScaleW, 0.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);
|
|
|
|
|
// Canvas.DrawSprite(Child);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// // 结束绘制
|
|
|
|
|
// Canvas.EndDraw();
|
|
|
|
|
// // 添加画布
|
|
|
|
|
// Addchild(Canvas);
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
//三分法拉伸
|
|
|
|
|
class Yosin_EmeStretch extends CL_CanvasObject {
|
|
|
|
|
|
|
|
|
|
Path = null;
|
|
|
|
|
Idx = null;
|
|
|
|
|
//按钮状态
|
|
|
|
|
SpriteList = null;
|
|
|
|
|
|
|
|
|
|
constructor(X, Y, W, H, Path, Idx, Direction = true) {
|
|
|
|
|
constructor( W, H, Path, Idx, Direction = true) {
|
|
|
|
|
this.Path = Path;
|
|
|
|
|
this.Idx = Idx;
|
|
|
|
|
base.constructor(X, Y, W, H);
|
|
|
|
|
base.constructor();
|
|
|
|
|
|
|
|
|
|
// 创建画布
|
|
|
|
|
local Canvas = CL_CanvasObject();
|
|
|
|
|
CL_CanvasObject();
|
|
|
|
|
// 重设大小并清空
|
|
|
|
|
Canvas.ResizeAndClear(W, H);
|
|
|
|
|
ResizeAndClear(W, H);
|
|
|
|
|
// 开始绘制
|
|
|
|
|
Canvas.BeginDraw();
|
|
|
|
|
BeginDraw();
|
|
|
|
|
|
|
|
|
|
SpriteList = [];
|
|
|
|
|
SpriteList.push(CL_SpriteObject(Path, Idx));
|
|
|
|
|
@ -187,224 +244,214 @@ class Yosin_EmeStretch extends Yosin_CommonUi {
|
|
|
|
|
|
|
|
|
|
foreach(Child in SpriteList) {
|
|
|
|
|
// Addchild(Child);
|
|
|
|
|
Canvas.DrawSprite(Child);
|
|
|
|
|
DrawSprite(Child);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 结束绘制
|
|
|
|
|
Canvas.EndDraw();
|
|
|
|
|
EndDraw();
|
|
|
|
|
// 添加画布
|
|
|
|
|
Addchild(Canvas);
|
|
|
|
|
// Addchild(Canvas);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 九宫格拉伸
|
|
|
|
|
function Yosin_NineBoxStretch(width, height, path, imgId) {
|
|
|
|
|
// function Yosin_NineBoxStretch(width, height, path, imgId) {
|
|
|
|
|
|
|
|
|
|
// 创建画布
|
|
|
|
|
local Canvas = CL_CanvasObject();
|
|
|
|
|
// 重设大小并清空
|
|
|
|
|
Canvas.ResizeAndClear(width, height);
|
|
|
|
|
// 开始绘制
|
|
|
|
|
Canvas.BeginDraw();
|
|
|
|
|
// // 创建画布
|
|
|
|
|
// local Canvas = CL_CanvasObject();
|
|
|
|
|
// // 重设大小并清空
|
|
|
|
|
// Canvas.ResizeAndClear(width, height);
|
|
|
|
|
// // 开始绘制
|
|
|
|
|
// Canvas.BeginDraw();
|
|
|
|
|
|
|
|
|
|
// 左上角
|
|
|
|
|
// local backgroundTopLeft = CL_SpriteObject(path, imgId);
|
|
|
|
|
local backgroundTopLeft = CL_SpriteObject(path, imgId);
|
|
|
|
|
// 上边
|
|
|
|
|
local backgroundTop = CL_SpriteObject(path, imgId + 1);
|
|
|
|
|
// 右上角
|
|
|
|
|
local backgroundTopRight = CL_SpriteObject(path, imgId + 2);
|
|
|
|
|
// 左边
|
|
|
|
|
local backgroundLeft = CL_SpriteObject(path, imgId + 3);
|
|
|
|
|
// 中间
|
|
|
|
|
local backgroundCenter = CL_SpriteObject(path, imgId + 4);
|
|
|
|
|
// 右边
|
|
|
|
|
local backgroundRight = CL_SpriteObject(path, imgId + 5);
|
|
|
|
|
// 左下角
|
|
|
|
|
local backgroundBottomLeft = CL_SpriteObject(path, imgId + 6);
|
|
|
|
|
// 下边
|
|
|
|
|
local backgroundBottom = CL_SpriteObject(path, imgId + 7);
|
|
|
|
|
// 右下角
|
|
|
|
|
local backgroundBottomRight = CL_SpriteObject(path, imgId + 8);
|
|
|
|
|
// // 左上角
|
|
|
|
|
// // local backgroundTopLeft = CL_SpriteObject(path, imgId);
|
|
|
|
|
// local backgroundTopLeft = CL_SpriteObject(path, imgId);
|
|
|
|
|
// // 上边
|
|
|
|
|
// local backgroundTop = CL_SpriteObject(path, imgId + 1);
|
|
|
|
|
// // 右上角
|
|
|
|
|
// local backgroundTopRight = CL_SpriteObject(path, imgId + 2);
|
|
|
|
|
// // 左边
|
|
|
|
|
// local backgroundLeft = CL_SpriteObject(path, imgId + 3);
|
|
|
|
|
// // 中间
|
|
|
|
|
// local backgroundCenter = CL_SpriteObject(path, imgId + 4);
|
|
|
|
|
// // 右边
|
|
|
|
|
// local backgroundRight = CL_SpriteObject(path, imgId + 5);
|
|
|
|
|
// // 左下角
|
|
|
|
|
// local backgroundBottomLeft = CL_SpriteObject(path, imgId + 6);
|
|
|
|
|
// // 下边
|
|
|
|
|
// local backgroundBottom = CL_SpriteObject(path, imgId + 7);
|
|
|
|
|
// // 右下角
|
|
|
|
|
// local backgroundBottomRight = CL_SpriteObject(path, imgId + 8);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 左上角
|
|
|
|
|
Canvas.DrawSprite(backgroundTopLeft);
|
|
|
|
|
// // 左上角
|
|
|
|
|
// Canvas.DrawSprite(backgroundTopLeft);
|
|
|
|
|
|
|
|
|
|
local TopLeftSize = backgroundTopLeft.GetSize();
|
|
|
|
|
local TopLeftBottom = TopLeftSize.h;
|
|
|
|
|
local TopLeftRight = TopLeftSize.w;
|
|
|
|
|
// local TopLeftSize = backgroundTopLeft.GetSize();
|
|
|
|
|
// local TopLeftBottom = TopLeftSize.h;
|
|
|
|
|
// local TopLeftRight = TopLeftSize.w;
|
|
|
|
|
|
|
|
|
|
// 中间图片大小
|
|
|
|
|
local centerImgSize = backgroundCenter.GetSize();
|
|
|
|
|
local centerImgWidth = centerImgSize.w;
|
|
|
|
|
local centerImgHeight = centerImgSize.h;
|
|
|
|
|
// // 中间图片大小
|
|
|
|
|
// local centerImgSize = backgroundCenter.GetSize();
|
|
|
|
|
// local centerImgWidth = centerImgSize.w;
|
|
|
|
|
// local centerImgHeight = centerImgSize.h;
|
|
|
|
|
|
|
|
|
|
local centerWidth = width - backgroundTopLeft.GetSize().w - backgroundTopRight.GetSize().w;
|
|
|
|
|
local centerHeight = height - backgroundTopLeft.GetSize().h - backgroundBottomLeft.GetSize().h;
|
|
|
|
|
// local centerWidth = width - backgroundTopLeft.GetSize().w - backgroundTopRight.GetSize().w;
|
|
|
|
|
// local centerHeight = height - backgroundTopLeft.GetSize().h - backgroundBottomLeft.GetSize().h;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local scaleW = (centerWidth - 1).tofloat() / centerImgWidth.tofloat();
|
|
|
|
|
local scaleH = (centerHeight - 1).tofloat() / centerImgHeight.tofloat();
|
|
|
|
|
// local scaleW = (centerWidth - 1).tofloat() / centerImgWidth.tofloat();
|
|
|
|
|
// local scaleH = (centerHeight - 1).tofloat() / centerImgHeight.tofloat();
|
|
|
|
|
|
|
|
|
|
// 上边
|
|
|
|
|
backgroundTop.SetScale(scaleW, 1);
|
|
|
|
|
backgroundTop.SetPosition(TopLeftRight, 0);
|
|
|
|
|
Canvas.DrawSprite(backgroundTop);
|
|
|
|
|
// // 上边
|
|
|
|
|
// backgroundTop.SetScale(scaleW, 1);
|
|
|
|
|
// backgroundTop.SetPosition(TopLeftRight, 0);
|
|
|
|
|
// Canvas.DrawSprite(backgroundTop);
|
|
|
|
|
|
|
|
|
|
// 右上角
|
|
|
|
|
backgroundTopRight.SetPosition(width - backgroundTopRight.GetSize().w - 1, 0);
|
|
|
|
|
Canvas.DrawSprite(backgroundTopRight);
|
|
|
|
|
// // 右上角
|
|
|
|
|
// backgroundTopRight.SetPosition(width - backgroundTopRight.GetSize().w - 1, 0);
|
|
|
|
|
// Canvas.DrawSprite(backgroundTopRight);
|
|
|
|
|
|
|
|
|
|
// 左边
|
|
|
|
|
backgroundLeft.SetScale(1, scaleH);
|
|
|
|
|
backgroundLeft.SetPosition(0, TopLeftBottom);
|
|
|
|
|
Canvas.DrawSprite(backgroundLeft);
|
|
|
|
|
// // 左边
|
|
|
|
|
// backgroundLeft.SetScale(1, scaleH);
|
|
|
|
|
// backgroundLeft.SetPosition(0, TopLeftBottom);
|
|
|
|
|
// Canvas.DrawSprite(backgroundLeft);
|
|
|
|
|
|
|
|
|
|
// 中间
|
|
|
|
|
backgroundCenter.SetScale(scaleW, scaleH);
|
|
|
|
|
// Addchild(backgroundCenter);
|
|
|
|
|
backgroundCenter.SetPosition(TopLeftRight, backgroundLeft.Y);
|
|
|
|
|
Canvas.DrawSprite(backgroundCenter);
|
|
|
|
|
// // 中间
|
|
|
|
|
// backgroundCenter.SetScale(scaleW, scaleH);
|
|
|
|
|
// // Addchild(backgroundCenter);
|
|
|
|
|
// backgroundCenter.SetPosition(TopLeftRight, backgroundLeft.Y);
|
|
|
|
|
// Canvas.DrawSprite(backgroundCenter);
|
|
|
|
|
|
|
|
|
|
// 右边
|
|
|
|
|
backgroundRight.SetScale(1, scaleH);
|
|
|
|
|
backgroundRight.SetPosition(width - backgroundRight.GetSize().w - 1, backgroundCenter.Y);
|
|
|
|
|
Canvas.DrawSprite(backgroundRight);
|
|
|
|
|
// // 右边
|
|
|
|
|
// backgroundRight.SetScale(1, scaleH);
|
|
|
|
|
// backgroundRight.SetPosition(width - backgroundRight.GetSize().w - 1, backgroundCenter.Y);
|
|
|
|
|
// Canvas.DrawSprite(backgroundRight);
|
|
|
|
|
|
|
|
|
|
// 左下角
|
|
|
|
|
backgroundBottomLeft.SetPosition(0, height - backgroundBottomLeft.GetSize().h - 1);
|
|
|
|
|
Canvas.DrawSprite(backgroundBottomLeft);
|
|
|
|
|
// // 左下角
|
|
|
|
|
// backgroundBottomLeft.SetPosition(0, height - backgroundBottomLeft.GetSize().h - 1);
|
|
|
|
|
// Canvas.DrawSprite(backgroundBottomLeft);
|
|
|
|
|
|
|
|
|
|
// 下边
|
|
|
|
|
backgroundBottom.SetScale(scaleW, 1);
|
|
|
|
|
backgroundBottom.SetPosition(TopLeftRight, backgroundBottomLeft.Y);
|
|
|
|
|
Canvas.DrawSprite(backgroundBottom);
|
|
|
|
|
// // 下边
|
|
|
|
|
// backgroundBottom.SetScale(scaleW, 1);
|
|
|
|
|
// backgroundBottom.SetPosition(TopLeftRight, backgroundBottomLeft.Y);
|
|
|
|
|
// Canvas.DrawSprite(backgroundBottom);
|
|
|
|
|
|
|
|
|
|
// 右下角
|
|
|
|
|
backgroundBottomRight.SetPosition(width - backgroundBottomRight.GetSize().w - 1, backgroundBottomLeft.Y);
|
|
|
|
|
Canvas.DrawSprite(backgroundBottomRight);
|
|
|
|
|
|
|
|
|
|
// 结束绘制
|
|
|
|
|
Canvas.EndDraw();
|
|
|
|
|
// 添加画布
|
|
|
|
|
// Addchild(Canvas);
|
|
|
|
|
local Sp = CL_SpriteObject();
|
|
|
|
|
Sp.SetFrame(Canvas.ExportSpriteFrame());
|
|
|
|
|
return Sp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// //九宫格拉伸
|
|
|
|
|
// 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 Canvas = CL_CanvasObject();
|
|
|
|
|
// // 重设大小并清空
|
|
|
|
|
// Canvas.ResizeAndClear(width, height);
|
|
|
|
|
// // 开始绘制
|
|
|
|
|
// Canvas.BeginDraw();
|
|
|
|
|
|
|
|
|
|
// // 左上角
|
|
|
|
|
// // local backgroundTopLeft = CL_SpriteObject(path, imgId);
|
|
|
|
|
// local backgroundTopLeft = CL_SpriteObject(path, imgId);
|
|
|
|
|
// // 上边
|
|
|
|
|
// local backgroundTop = CL_SpriteObject(path, imgId + 1);
|
|
|
|
|
// // 右上角
|
|
|
|
|
// local backgroundTopRight = CL_SpriteObject(path, imgId + 2);
|
|
|
|
|
// // 左边
|
|
|
|
|
// local backgroundLeft = CL_SpriteObject(path, imgId + 3);
|
|
|
|
|
// // 中间
|
|
|
|
|
// local backgroundCenter = CL_SpriteObject(path, imgId + 4);
|
|
|
|
|
// // 右边
|
|
|
|
|
// local backgroundRight = CL_SpriteObject(path, imgId + 5);
|
|
|
|
|
// // 左下角
|
|
|
|
|
// local backgroundBottomLeft = CL_SpriteObject(path, imgId + 6);
|
|
|
|
|
// // 下边
|
|
|
|
|
// local backgroundBottom = CL_SpriteObject(path, imgId + 7);
|
|
|
|
|
// // 右下角
|
|
|
|
|
// local backgroundBottomRight = CL_SpriteObject(path, imgId + 8);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// // 左上角
|
|
|
|
|
// Canvas.DrawSprite(backgroundTopLeft);
|
|
|
|
|
|
|
|
|
|
// local TopLeftSize = backgroundTopLeft.GetSize();
|
|
|
|
|
// local TopLeftBottom = TopLeftSize.h;
|
|
|
|
|
// local TopLeftRight = TopLeftSize.w;
|
|
|
|
|
|
|
|
|
|
// // 中间图片大小
|
|
|
|
|
// local centerImgSize = backgroundCenter.GetSize();
|
|
|
|
|
// local centerImgWidth = centerImgSize.w;
|
|
|
|
|
// local centerImgHeight = centerImgSize.h;
|
|
|
|
|
|
|
|
|
|
// local centerWidth = width - backgroundTopLeft.GetSize().w - backgroundTopRight.GetSize().w;
|
|
|
|
|
// local centerHeight = height - backgroundTopLeft.GetSize().h - backgroundBottomLeft.GetSize().h;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// local scaleW = (centerWidth - 1).tofloat() / centerImgWidth.tofloat();
|
|
|
|
|
// local scaleH = (centerHeight - 1).tofloat() / centerImgHeight.tofloat();
|
|
|
|
|
|
|
|
|
|
// // 上边
|
|
|
|
|
// backgroundTop.SetScale(scaleW, 1);
|
|
|
|
|
// backgroundTop.SetPosition(TopLeftRight + 1, 0);
|
|
|
|
|
// Canvas.DrawSprite(backgroundTop);
|
|
|
|
|
|
|
|
|
|
// // 右上角
|
|
|
|
|
// backgroundTopRight.SetPosition(width - backgroundTopRight.GetSize().w, 0);
|
|
|
|
|
// Canvas.DrawSprite(backgroundTopRight);
|
|
|
|
|
|
|
|
|
|
// // 左边
|
|
|
|
|
// backgroundLeft.SetScale(1, scaleH);
|
|
|
|
|
// backgroundLeft.SetPosition(0, TopLeftBottom + 1);
|
|
|
|
|
// Canvas.DrawSprite(backgroundLeft);
|
|
|
|
|
|
|
|
|
|
// // 中间
|
|
|
|
|
// backgroundCenter.SetScale(scaleW, scaleH);
|
|
|
|
|
// // Addchild(backgroundCenter);
|
|
|
|
|
// backgroundCenter.SetPosition(TopLeftRight + 1, backgroundLeft.Y);
|
|
|
|
|
// Canvas.DrawSprite(backgroundCenter);
|
|
|
|
|
|
|
|
|
|
// // 右边
|
|
|
|
|
// backgroundRight.SetScale(1, scaleH);
|
|
|
|
|
// backgroundRight.SetPosition(width - backgroundRight.GetSize().w, backgroundCenter.Y);
|
|
|
|
|
// Canvas.DrawSprite(backgroundRight);
|
|
|
|
|
|
|
|
|
|
// // 左下角
|
|
|
|
|
// backgroundBottomLeft.SetPosition(0, height - backgroundBottomLeft.GetSize().h);
|
|
|
|
|
// Canvas.DrawSprite(backgroundBottomLeft);
|
|
|
|
|
|
|
|
|
|
// // 下边
|
|
|
|
|
// backgroundBottom.SetScale(scaleW, 1);
|
|
|
|
|
// backgroundBottom.SetPosition(TopLeftRight + 1, backgroundBottomLeft.Y);
|
|
|
|
|
// Canvas.DrawSprite(backgroundBottom);
|
|
|
|
|
|
|
|
|
|
// // 右下角
|
|
|
|
|
// backgroundBottomRight.SetPosition(width - backgroundBottomRight.GetSize().w, backgroundBottomLeft.Y);
|
|
|
|
|
// Canvas.DrawSprite(backgroundBottomRight );
|
|
|
|
|
|
|
|
|
|
// // 结束绘制
|
|
|
|
|
// Canvas.EndDraw();
|
|
|
|
|
// // 添加画布
|
|
|
|
|
// Addchild(Canvas);
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
// // 右下角
|
|
|
|
|
// backgroundBottomRight.SetPosition(width - backgroundBottomRight.GetSize().w - 1, backgroundBottomLeft.Y);
|
|
|
|
|
// Canvas.DrawSprite(backgroundBottomRight);
|
|
|
|
|
|
|
|
|
|
// // 结束绘制
|
|
|
|
|
// Canvas.EndDraw();
|
|
|
|
|
// // 添加画布
|
|
|
|
|
// // Addchild(Canvas);
|
|
|
|
|
// local Sp = CL_SpriteObject();
|
|
|
|
|
// Sp.SetFrame(Canvas.ExportSpriteFrame());
|
|
|
|
|
// return Sp;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//九宫格拉伸
|
|
|
|
|
class Yosin_NineBoxStretch extends CL_CanvasObject {
|
|
|
|
|
|
|
|
|
|
constructor( width, height, path, imgId) {
|
|
|
|
|
base.constructor();
|
|
|
|
|
|
|
|
|
|
// 创建画布
|
|
|
|
|
CL_CanvasObject();
|
|
|
|
|
// 重设大小并清空
|
|
|
|
|
ResizeAndClear(width, height);
|
|
|
|
|
|
|
|
|
|
// 开始绘制
|
|
|
|
|
BeginDraw();
|
|
|
|
|
|
|
|
|
|
// 左上角
|
|
|
|
|
local backgroundTopLeft = CL_SpriteObject(path, imgId);
|
|
|
|
|
// 上边
|
|
|
|
|
local backgroundTop = CL_SpriteObject(path, imgId + 1);
|
|
|
|
|
// 右上角
|
|
|
|
|
local backgroundTopRight = CL_SpriteObject(path, imgId + 2);
|
|
|
|
|
// 左边
|
|
|
|
|
local backgroundLeft = CL_SpriteObject(path, imgId + 3);
|
|
|
|
|
// 中间
|
|
|
|
|
local backgroundCenter = CL_SpriteObject(path, imgId + 4);
|
|
|
|
|
// 右边
|
|
|
|
|
local backgroundRight = CL_SpriteObject(path, imgId + 5);
|
|
|
|
|
// 左下角
|
|
|
|
|
local backgroundBottomLeft = CL_SpriteObject(path, imgId + 6);
|
|
|
|
|
// 下边
|
|
|
|
|
local backgroundBottom = CL_SpriteObject(path, imgId + 7);
|
|
|
|
|
// 右下角
|
|
|
|
|
local backgroundBottomRight = CL_SpriteObject(path, imgId + 8);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 左上角
|
|
|
|
|
DrawSprite(backgroundTopLeft);
|
|
|
|
|
|
|
|
|
|
local TopLeftSize = backgroundTopLeft.GetSize();
|
|
|
|
|
local TopLeftBottom = TopLeftSize.h;
|
|
|
|
|
local TopLeftRight = TopLeftSize.w;
|
|
|
|
|
|
|
|
|
|
// 中间图片大小
|
|
|
|
|
local centerImgSize = backgroundCenter.GetSize();
|
|
|
|
|
local centerImgWidth = centerImgSize.w;
|
|
|
|
|
local centerImgHeight = centerImgSize.h;
|
|
|
|
|
|
|
|
|
|
local centerWidth = width - backgroundTopLeft.GetSize().w - backgroundTopRight.GetSize().w;
|
|
|
|
|
local centerHeight = height - backgroundTopLeft.GetSize().h - backgroundBottomLeft.GetSize().h;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local scaleW = (centerWidth - 1).tofloat() / centerImgWidth.tofloat();
|
|
|
|
|
local scaleH = (centerHeight - 1).tofloat() / centerImgHeight.tofloat();
|
|
|
|
|
|
|
|
|
|
// 上边
|
|
|
|
|
backgroundTop.SetScale(scaleW, 1);
|
|
|
|
|
backgroundTop.SetPosition(TopLeftRight, 0);
|
|
|
|
|
DrawSprite(backgroundTop);
|
|
|
|
|
|
|
|
|
|
// 右上角
|
|
|
|
|
backgroundTopRight.SetPosition(width - backgroundTopRight.GetSize().w - 1, 0);
|
|
|
|
|
DrawSprite(backgroundTopRight);
|
|
|
|
|
|
|
|
|
|
// 左边
|
|
|
|
|
backgroundLeft.SetScale(1, scaleH);
|
|
|
|
|
backgroundLeft.SetPosition(0, TopLeftBottom);
|
|
|
|
|
DrawSprite(backgroundLeft);
|
|
|
|
|
|
|
|
|
|
// 中间
|
|
|
|
|
backgroundCenter.SetScale(scaleW, scaleH);
|
|
|
|
|
// Addchild(backgroundCenter);
|
|
|
|
|
backgroundCenter.SetPosition(TopLeftRight, backgroundLeft.Y);
|
|
|
|
|
DrawSprite(backgroundCenter);
|
|
|
|
|
|
|
|
|
|
// 右边
|
|
|
|
|
backgroundRight.SetScale(1, scaleH);
|
|
|
|
|
backgroundRight.SetPosition(width - backgroundRight.GetSize().w - 1, backgroundCenter.Y);
|
|
|
|
|
DrawSprite(backgroundRight);
|
|
|
|
|
|
|
|
|
|
// 左下角
|
|
|
|
|
backgroundBottomLeft.SetPosition(0, height - backgroundBottomLeft.GetSize().h - 1);
|
|
|
|
|
DrawSprite(backgroundBottomLeft);
|
|
|
|
|
|
|
|
|
|
// 下边
|
|
|
|
|
backgroundBottom.SetScale(scaleW, 1);
|
|
|
|
|
backgroundBottom.SetPosition(TopLeftRight, backgroundBottomLeft.Y);
|
|
|
|
|
DrawSprite(backgroundBottom);
|
|
|
|
|
|
|
|
|
|
// 右下角
|
|
|
|
|
backgroundBottomRight.SetPosition(width - backgroundBottomRight.GetSize().w - 1, backgroundBottomLeft.Y);
|
|
|
|
|
DrawSprite(backgroundBottomRight);
|
|
|
|
|
|
|
|
|
|
// 结束绘制
|
|
|
|
|
EndDraw();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//拼接按钮
|
|
|
|
|
class Yosin_SplicingButton extends Yosin_CommonUi {
|
|
|
|
|
//按钮状态
|
|
|
|
|
@ -427,14 +474,14 @@ class Yosin_SplicingButton extends Yosin_CommonUi {
|
|
|
|
|
SpriteList = array(4);
|
|
|
|
|
|
|
|
|
|
//普通态
|
|
|
|
|
SpriteList[0] = Yosin_EmeStretch(0, 0, W, H, Path, Idx, Direction);
|
|
|
|
|
SpriteList[0] = Yosin_EmeStretch( W, H, Path, Idx, Direction);
|
|
|
|
|
//悬停态
|
|
|
|
|
SpriteList[1] = Yosin_EmeStretch(0, 0, W, H, Path, Idx + (UnavailableFlag ? 4 : 3), Direction);
|
|
|
|
|
SpriteList[1] = Yosin_EmeStretch( W, H, Path, Idx + (UnavailableFlag ? 4 : 3), Direction);
|
|
|
|
|
//按下态
|
|
|
|
|
SpriteList[2] = Yosin_EmeStretch(0, 0, W, H, Path, Idx + (UnavailableFlag ? 8 : 6), Direction);
|
|
|
|
|
SpriteList[2] = Yosin_EmeStretch( W, H, Path, Idx + (UnavailableFlag ? 8 : 6), Direction);
|
|
|
|
|
if (UnavailableFlag) {
|
|
|
|
|
//不可用态
|
|
|
|
|
SpriteList[3] = Yosin_EmeStretch(0, 0, W, H, Path, Idx + 12, Direction);
|
|
|
|
|
SpriteList[3] = Yosin_EmeStretch( W, H, Path, Idx + 12, Direction);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -455,7 +502,7 @@ class Yosin_SplicingButton extends Yosin_CommonUi {
|
|
|
|
|
RemoveUIChild(SpriteList[SpriteState]);
|
|
|
|
|
}
|
|
|
|
|
SpriteState = State;
|
|
|
|
|
AddUIChild(SpriteList[SpriteState]);
|
|
|
|
|
Addchild(SpriteList[SpriteState]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -588,17 +635,17 @@ class Yosin_StretchTitleButton extends Yosin_CommonUi {
|
|
|
|
|
SpriteList = array(3);
|
|
|
|
|
|
|
|
|
|
//普通态
|
|
|
|
|
SpriteList[0] = Yosin_EmeStretch(0, 0, W, H, Path, Idx);
|
|
|
|
|
AddUIChild(SpriteList[0]);
|
|
|
|
|
SpriteList[0] = Yosin_EmeStretch( W, H, Path, Idx);
|
|
|
|
|
Addchild(SpriteList[0]);
|
|
|
|
|
|
|
|
|
|
//悬停态
|
|
|
|
|
SpriteList[1] = Yosin_EmeStretch(0, 0, W, H, Path, Idx + 3);
|
|
|
|
|
SpriteList[1] = Yosin_EmeStretch( W, H, Path, Idx + 3);
|
|
|
|
|
SpriteList[1].SetVisible(false)
|
|
|
|
|
AddUIChild(SpriteList[1]);
|
|
|
|
|
Addchild(SpriteList[1]);
|
|
|
|
|
//按下态
|
|
|
|
|
SpriteList[2] = Yosin_EmeStretch(0, 0, W, H, Path, Idx + 6);
|
|
|
|
|
SpriteList[2] = Yosin_EmeStretch( W, H, Path, Idx + 6);
|
|
|
|
|
SpriteList[2].SetVisible(false)
|
|
|
|
|
AddUIChild(SpriteList[2]);
|
|
|
|
|
Addchild(SpriteList[2]);
|
|
|
|
|
|
|
|
|
|
// 文字
|
|
|
|
|
titleText = FontAssetManager.GenerateNormal(title, true, {
|
|
|
|
|
|