67 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
			
		
		
	
	
			67 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
/*
 | 
						|
文件名:TextActor.nut
 | 
						|
路径:Core/BaseClass/TextObject/TextActor.nut
 | 
						|
创建日期:2024-12-01	19:51
 | 
						|
文件用途:文本样式
 | 
						|
*/
 | 
						|
class TextActor extends CL_BaseObject {
 | 
						|
 | 
						|
    //不需要Update函数
 | 
						|
    NoUpdate = true;
 | 
						|
 | 
						|
    /*
 | 
						|
     * @函数作用: 构造文本精灵
 | 
						|
     * @参数 font 可传入全局font Id 或 传入 font对象
 | 
						|
     * @参数 textstyle Map 可选对象:
 | 
						|
        alignment 对其方式
 | 
						|
        wrap_width 自动换行宽度
 | 
						|
        line_spacing 行间距
 | 
						|
        show_underline 显示下划线
 | 
						|
        show_strikethrough 	显示删除线
 | 
						|
        color 颜色
 | 
						|
     * @返回值
 | 
						|
    */
 | 
						|
    constructor(font, textstyle = {}) {
 | 
						|
        switch (typeof font) {
 | 
						|
            case "integer":
 | 
						|
                C_Object = TextActor_Create(__Font__Map__[font].C_Object, textstyle);
 | 
						|
                break;
 | 
						|
            case "font_data":
 | 
						|
                C_Object = TextActor_Create(font.C_Object, textstyle);
 | 
						|
                break;
 | 
						|
            default:
 | 
						|
                C_Object = TextActor_Create(Font().C_Object, textstyle);
 | 
						|
                break;
 | 
						|
        }
 | 
						|
        //传递字体类
 | 
						|
        base.constructor(C_Object);
 | 
						|
    }
 | 
						|
 | 
						|
    //设置文本内容
 | 
						|
    function SetText(str) {
 | 
						|
        TextActor_SetText(this.C_Object, str);
 | 
						|
    }
 | 
						|
 | 
						|
    //设置描边
 | 
						|
    function SetOutline(color = Color.Black, flag = true) {
 | 
						|
        TextActor_SetOutLine(this.C_Object, color, flag);
 | 
						|
    }
 | 
						|
 | 
						|
    // //设置描边
 | 
						|
    // function SetOutline(style) {
 | 
						|
    //     OutlineChild = [];
 | 
						|
    //     for (local i = 0; i< 8; i++) {
 | 
						|
    //         style.color = 0xff000000;
 | 
						|
    //         local buf = FontAssetManager.GenerateNormal("", false, style);
 | 
						|
    //         buf.SetPosition(Strokeoffsets[i]);
 | 
						|
    //         buf.SetZOrder(-1);
 | 
						|
    //         OutlineChild.push(buf);
 | 
						|
    //         Addchild(buf);
 | 
						|
    //     }
 | 
						|
    // }
 | 
						|
 | 
						|
    //设置填充颜色
 | 
						|
    function SetFillColor(Color) {
 | 
						|
        TextActor_SetFillColor(this.C_Object, Color);
 | 
						|
    }
 | 
						|
} |