鍍金池/ 問答/HTML5  Python  HTML/ egret點擊跳轉(zhuǎn)頁面

egret點擊跳轉(zhuǎn)頁面

egret點擊跳轉(zhuǎn)頁面,有這個功能?

回答
編輯回答
我以為

class Main extends egret.DisplayObjectContainer {

constructor() {
    super();   
    this.addEventListener(egret.Event.ADDED_TO_STAGE, this.onAddToStage, this);
}

   private _txInfo11:egret.TextField;
   private container1;
  
private onAddToStage(event:egret.Event) {


     this.container1 = new egret.DisplayObjectContainer();
      var robot:Robot = new Robot();
     this.container1.addChild(robot);

    this._txInfo11 = new egret.TextField;
    this.addChild( this._txInfo11 );
    this._txInfo11.size = 28;
    this._txInfo11.x = 400;
    this._txInfo11.y = 10;
    this._txInfo11.text = "換頁";


     var _bgInfo11:egret.Sprite = new egret.Sprite();
    this.addChildAt(_bgInfo11, this.numChildren - 1 );

   _bgInfo11.x = this._txInfo11.x;
    _bgInfo11.y = this._txInfo11.y;
   _bgInfo11.graphics.clear();
    _bgInfo11.graphics.beginFill( 0xff7f50, .5 );
    _bgInfo11.graphics.drawRect( 0, 0, this._txInfo11.width, this._txInfo11.height );
   _bgInfo11.graphics.endFill();
     _bgInfo11.touchEnabled = true;
     _bgInfo11.addEventListener( egret.TouchEvent.TOUCH_TAP, ()=>{
               if(this.contains(this.container1)){
            this.removeChild(this.container1);
          
        }else{

            this.addChild(this.container1);
             
        }
    }, this );  



}

}

2018年4月10日 09:30
編輯回答
莫小染

如果是外鏈,直接 window.location.href跳轉(zhuǎn)就可以了

如果是游戲頁面切換,直接移除之前的,在舞臺上重新實例化一個就可以了

2018年6月7日 16:56