新增 迷你数字类 返回为画布对象
This commit is contained in:
parent
5d38428f30
commit
da0e76a02c
|
|
@ -0,0 +1,39 @@
|
||||||
|
/*
|
||||||
|
文件名:Mininumber.nut
|
||||||
|
路径:User/UI/Widget/Mininumber.nut
|
||||||
|
创建日期:2025-01-20 17:49
|
||||||
|
文件用途:
|
||||||
|
*/
|
||||||
|
//迷你数字
|
||||||
|
class Yosin_Mininumber extends CL_CanvasObject {
|
||||||
|
|
||||||
|
//图片数字宽度
|
||||||
|
Yosin_Mininumber_NumberWidth = [6, 4, 6, 6, 6, 6, 6, 6, 6, 6];
|
||||||
|
|
||||||
|
// 构造函数
|
||||||
|
constructor(Number) {
|
||||||
|
|
||||||
|
if (typeof Number != "integer") error("参数错误");
|
||||||
|
local NumberString = Number.tostring();
|
||||||
|
|
||||||
|
base.constructor();
|
||||||
|
|
||||||
|
// 创建画布
|
||||||
|
CL_CanvasObject();
|
||||||
|
// 重设大小并清空
|
||||||
|
ResizeAndClear(NumberString.len() * 6, 10);
|
||||||
|
// 开始绘制
|
||||||
|
BeginDraw();
|
||||||
|
|
||||||
|
local DrawTextWidth = 0;
|
||||||
|
foreach(value in NumberString) {
|
||||||
|
local realnum = value - 48;
|
||||||
|
DrawSpriteFrame(CL_SpriteFrameObject("sprite/interface/mininumberset.img", realnum), DrawTextWidth, 0);
|
||||||
|
DrawTextWidth += Yosin_Mininumber_NumberWidth[realnum];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 结束绘制
|
||||||
|
EndDraw();
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue