Merge pull request '加入文本精灵' (#5) from Lenheart into master
Reviewed-on: http://49.234.27.222:3000/Lenheart/DNF_DEV_SQR/pulls/5
This commit is contained in:
@@ -20,6 +20,7 @@ UI/ObjectClass/Actor.nut
|
||||
UI/ObjectClass/WindowNode.nut
|
||||
UI/ObjectClass/GameWindow.nut
|
||||
UI/ObjectClass/GameWidget.nut
|
||||
UI/ObjectClass/Text.nut
|
||||
UI/ObjectClass/Sprite.nut
|
||||
UI/ObjectClass/Canvas.nut
|
||||
|
||||
|
||||
@@ -22,3 +22,20 @@ function print(Object) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回颜色的十六进制数
|
||||
* @function
|
||||
* @param {any} R
|
||||
* @param {any} G
|
||||
* @param {any} B
|
||||
* @param {any} A
|
||||
* @returns {*}
|
||||
*/
|
||||
function sq_RGBA(R, G, B, A) {
|
||||
R = R.tointeger();
|
||||
G = G.tointeger();
|
||||
B = B.tointeger();
|
||||
A = A.tointeger();
|
||||
return (A << 24) + (R << 16) + (G << 8) + B;
|
||||
}
|
||||
@@ -20,15 +20,15 @@ function _MainUI_Enter_(UI_Scene) {
|
||||
// _SYS_UI_SCENE_Instance_.AddChild(Tc);
|
||||
// Tc.SetPos(400,300);
|
||||
|
||||
local NgC = GameWidget_NineGridCav("sprite/interface/lenheartwindowcommon.img", 97, 300, 300);
|
||||
_SYS_UI_SCENE_Instance_.AddChild(NgC);
|
||||
NgC.SetPos(400, 300);
|
||||
// local NgC = GameWidget_NineGridCav("sprite/interface/lenheartwindowcommon.img", 97, 300, 300);
|
||||
// _SYS_UI_SCENE_Instance_.AddChild(NgC);
|
||||
// NgC.SetPos(400, 300);
|
||||
|
||||
// local T = sq_GetPng("sprite/item/avatar/swordman/0sm_acap.img",0);
|
||||
// print(T);
|
||||
|
||||
// local Test1 = sq_CreaterWindowInstance("测试窗口", Window_NotiBox, 150, 150, 364, 356, 20);
|
||||
// Test1.ResetFoucus();
|
||||
local Test1 = sq_CreaterWindowInstance("测试窗口", Window_NotiBox, 150, 150, 364, 356, 20);
|
||||
Test1.ResetFoucus();
|
||||
|
||||
// local Canv = Canvas(600, 600);
|
||||
// _SYS_UI_SCENE_Instance_.AddChild(Canv);
|
||||
|
||||
@@ -65,7 +65,7 @@ class GameWidget extends WindowNode {
|
||||
local IMouse = Game_Cursor.GetInstance();
|
||||
local Pos = GetWorldPos();
|
||||
if (isLBDown && Math.IsIntersectRect(IMouse.MouseX, IMouse.MouseY, 1, 1, Pos.x, Pos.y, Width, Height)) {
|
||||
if (OnClick) this.OnClick(this);
|
||||
if (OnClick) this.OnClick.call(this,this);
|
||||
if (ClickSound) {
|
||||
//TODO 音效系统
|
||||
// Sq_PlaySoundEffect(ClickSound);
|
||||
|
||||
16
UI/ObjectClass/Text.nut
Normal file
16
UI/ObjectClass/Text.nut
Normal file
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
文件名:Text.nut
|
||||
路径:UI/ObjectClass/Text.nut
|
||||
创建日期:2025-10-25 15:40
|
||||
文件用途:
|
||||
*/
|
||||
class Text extends Actor {
|
||||
function _typeof() {
|
||||
return "Text"
|
||||
}
|
||||
|
||||
constructor(Str, FontIndex,Color) {
|
||||
C_Object = sq_CreateText(Str, FontIndex, Color);
|
||||
sq_RegisterDestruction(C_Object,this);
|
||||
}
|
||||
}
|
||||
@@ -6,20 +6,33 @@
|
||||
*/
|
||||
|
||||
class Window_NotiBox extends GameWindow {
|
||||
testvalue = 666;
|
||||
|
||||
constructor(Name, gX, gY, gWidth, gHeight, gTitleHeight) {
|
||||
base.constructor(Name, gX, gY, gWidth, gHeight, gTitleHeight);
|
||||
|
||||
InitSprite();
|
||||
InitButton();
|
||||
// InitButton();
|
||||
}
|
||||
|
||||
function InitSprite() {
|
||||
local Sp = Sprite("sprite/hud/newantonui.img", 0);
|
||||
AddChild(Sp);
|
||||
|
||||
local Textobj = Text("测试文本",0,sq_RGBA(255,255,255,255));
|
||||
AddChild(Textobj);
|
||||
local Textobj2 = Text("测试文本",1,sq_RGBA(255,255,255,255));
|
||||
Textobj2.SetPos(0,50);
|
||||
AddChild(Textobj2);
|
||||
}
|
||||
|
||||
function InitButton() {
|
||||
local Btn = GameWidget_BaseButton(40, 40, 56, 24, "sprite/interface/lenheartwindowcommon.img", 12);
|
||||
Btn.OnClick = function(btn){
|
||||
// print(testvalue);
|
||||
print(this);
|
||||
print(btn);
|
||||
}.bindenv(this);
|
||||
AddChild(Btn);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,5 +85,8 @@
|
||||
},
|
||||
"UI/Windows/Widget/NineGridCav.nut": {
|
||||
"description": "九宫格画布"
|
||||
},
|
||||
"UI/ObjectClass/Text.nut": {
|
||||
"description": "文本类"
|
||||
}
|
||||
}
|
||||
@@ -95,6 +95,7 @@ function sq_CreateActor() {}
|
||||
function sq_RegisterDestruction(a,b) {}
|
||||
function sq_CreateSprite(a,b) {}
|
||||
function sq_CreateCanvas(a,b) {}
|
||||
function sq_CreateText(a,b,c) {}
|
||||
function sq_AddChild(a,b){}
|
||||
function sq_RemoveChild(a,b){}
|
||||
function sq_SetZOrder(a,b){}
|
||||
|
||||
10
main.nut
10
main.nut
@@ -1,9 +1,15 @@
|
||||
function _InitFont_() {
|
||||
return [
|
||||
{ path = "Fonts/VonwaonBitmap-12px.ttf", size = 12 },
|
||||
{ path = "Fonts/VonwaonBitmap-12px.ttf", size = 24 },
|
||||
{ path = "Fonts/NotoSansSC-Light.otf", size = 12 }
|
||||
];
|
||||
}
|
||||
|
||||
function main() {
|
||||
//初始化随机数种子
|
||||
srand(time());
|
||||
|
||||
|
||||
|
||||
local SM = StateMachine.GetInstance();
|
||||
|
||||
SM.RegisterState(CHARACTERJOB.SWORDMAN, "Character_Rest", 0);
|
||||
|
||||
Reference in New Issue
Block a user