Laya学习笔记-01文本类

一、用的代码创建一个UI文本

export default class TestText extends Laya.Script {

    constructor() {
        super();
    }

    onAwake() {

       //用代码创建一个UI文本
       var tex=new Laya.Text();
       //设置文本内容
       tex.text="Hello World";
       //设置字体大小
       tex.fontSize=90;
       //设置字体颜色
       tex.color="#ffffff";
       //设置字体边框
       tex.size(400,200);
       //设置字体的位置
       tex.pos(781.5,454);
       //将UI添加到舞台上
       Laya.stage.addChild(tex);

    }
}

二、文本类常用的API

1

参考资料:

文本类API:https://layaair.ldc.layabox.com/api/index.html?category=Core&class=laya.display.Text 

官网教程:https://ldc2.layabox.com/doc/?nav=zh-ts-1-2-2

猜你喜欢

转载自blog.csdn.net/a451319296/article/details/106302738