• TypeScript笔记


    显示文字:

    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.textAlign = egret.HorizontalAlign.CENTER;//水平方向居中
    this.textInput.verticalAlign = egret.VerticalAlign.MIDDLE;//垂直方向居中
    this.textInput.inputType = egret.TextFieldInputType.PASSWORD;//密码
    this.textInput.displayAsPassword=true;//启用密码
    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);

     APP进入前后台的判断

    egret.lifecycle.addLifecycleListener((context) => {
                // custom lifecycle plugin
            })
    
            egret.lifecycle.onPause = () => {
                    console.log("app 进入后台");
                    egret.ticker.pause(); // 关闭渲染与心跳
            }
    
            egret.lifecycle.onResume = () => {
                    console.log("app 进入前台");
                    egret.ticker.resume(); // 打开渲染与心跳
            }

    遮罩(显示mask部分)

          var mask:egret.Rectangle=new egret.Rectangle(0,0,50,50);//显示的区域
          this._shap=new egret.Shape();
          this._shap.graphics.beginFill(0xff0000);
          this._shap.graphics.drawRect( 0,0,100,100);
          this._shap.graphics.endFill();
          this.addChild(this._shap);
          this._shap.mask=mask; //为某个对象设置遮罩    

    碰撞检测:

    var isHit:boolean=myShap.hitTestPoint(this._pos.x,this._pos.y);//检测myShap对象的x,y位置知否发生了碰撞
  • 相关阅读:
    windows10家庭版安装docker踩坑解决记录
    sequelize Getters, Setters & Virtuals
    sequelize模型增删改查询(基础)Model Querying
    sequelize数据库模型关联文档详解
    Nginx配置实现下载文件
    Linux常用命令记录
    nodejs后台如何请求第三方接口request-promise简介及其废弃后的替代方案推荐got、axios
    新版本chrome浏览器(80版本以后)带来的跨域请求cookie丢失问题
    谷歌浏览器 Cookie 的 SameSite 属性 (转)
    JavaScript Image对象 整理
  • 原文地址:https://www.cnblogs.com/shirln/p/9224460.html
Copyright © 2020-2023  润新知