zoukankan      html  css  js  c++  java
  • 白鹭学习笔记1

     如果入口是Main.ts的Main类

    private textfield: egret.TextField;
    private _txInfo:egret.TextField;
    private _bgInfo:egret.Shape;
    /**
    * 创建场景界面
    * Create scene interface
    */
    protected createGameScene(): void {

    /*** 本示例关键代码段开始 ***/
    // 创建图片,比如背景图、或者在某个位置显示一种图片
    var bird:egret.Bitmap = new egret.Bitmap();
    bird.texture = RES.getRes("egret_icon_png");
    bird.x = this.stage.stageWidth / 2;
    bird.y = this.stage.stageHeight / 2;
    this.addChild( bird );
    /*** 本示例关键代码段结束 ***/

    /// 为定位设置基准点(即锚点)
    bird.anchorOffsetX = bird.width / 2;
    bird.anchorOffsetY = bird.height / 2;
    bird.x = this.stage.stageWidth * .5;
    bird.y = this.stage.stageHeight * .5;

    /// 提示信息
    this._txInfo = new egret.TextField;
    this.addChild( this._txInfo );

    this._txInfo.size = 28;
    this._txInfo.x = 50;
    this._txInfo.y = 50;
    this._txInfo.textAlign = egret.HorizontalAlign.LEFT;
    this._txInfo.textColor = 0x000000;
    this._txInfo.type = egret.TextFieldType.DYNAMIC;
    this._txInfo.lineSpacing = 6;
    this._txInfo.multiline = true;

    this._txInfo.text =
    "轻触屏幕调整显示对象位置";

    this._bgInfo = new egret.Shape;
    this.addChildAt( this._bgInfo, this.numChildren - 1 );

    this._bgInfo.x = this._txInfo.x;
    this._bgInfo.y = this._txInfo.y;
    this._bgInfo.graphics.clear();
    this._bgInfo.graphics.beginFill( 0xff0000, 0.5 );
    this._bgInfo.graphics.drawRect( 0, 0, this._txInfo.width, this._txInfo.height );
    this._bgInfo.graphics.endFill();

    this.stage.addEventListener( egret.TouchEvent.TOUCH_BEGIN, ( evt:egret.TouchEvent )=>{
    bird.x = evt.localX ;
    bird.y = evt.localY ;
    }, this );

    }

     效果图

  • 相关阅读:
    编译安装LAMP之php-5.4.13、xcache-2.0及使用ab命令实现压力测试
    编译安装LAMP之MySQL-5.5.28(通用二进制格式)
    编译安装LAMP之httpd-2.4.4
    建立LAMP平台
    MySQL初步,数据类型及SQL语句
    数据库及MySQL
    PHP相关概念及配置
    CSS:页面美化和布局控制
    HTML标签:表单标签
    web概念简述,HTML学习笔记
  • 原文地址:https://www.cnblogs.com/kuainiao/p/9355894.html
Copyright © 2011-2022 走看看