zoukankan      html  css  js  c++  java
  • 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位置知否发生了碰撞
  • 相关阅读:
    vue+elemnet 实现自定义参数
    css 实现鼠标移上去标题向右滑动的效果
    vue 搜索关键字列表结果高亮显示
    leaflet 实现 测距、测面、清除测量的功能
    js对象的合并
    formdata的使用方法
    fromdata上传多个文件
    3.11formdata的使用
    微信小程序的自定义插件
    3.6
  • 原文地址:https://www.cnblogs.com/shirln/p/9224460.html
Copyright © 2011-2022 走看看