显示文字:
this.textTips = new egret.TextField; this.textTips.size = 24; this.textTips.textAlign = egret.HorizontalAlign.CENTER; this.textTips.textColor = 0x843900; this.textTips.x = this.stage.stageWidth / 2 - this.textTips.width / 2; this.textTips.y = this.stage.stageHeight - 100; this.addChild(this.textTips); this.textTips.text = "Hello world";
输入框:
this.textInput = new egret.TextField; this.textInput.size = 50; this.textInput.type = "input"; this.textInput.width = 300; this.textInput.height = 300; this.textInput.border = true; this.textInput.borderColor = 0x000000; this.textInput.textAlign = egret.HorizontalAlign.CENTER; this.textInput.textColor = 0x77787b; this.textInput.text = "请输入你要输入的内容"; this.textInput.x = this.stage.stageWidth / 2 - this.textInput.width / 2; this.textInput.y = 200; this.textInput.touchEnabled = true; this.addChild(this.textInput);
//添加监听事件
this.textInput.addEventListener(egret.TouchEvent.TOUCH_TAP, () => {
this.textInput.text = ""; //点击输入框的默认值
this.textInput.textColor = 0x000000;
}, this);