Jump to content

Input events


Kamaz
 Share

Recommended Posts

I draw all the game objects (images, animations, fonts) using renderTexture in State.Update(). 
Is there any way to handle mouse events? Without adding to the stage.

Simple example, events don't work:

public create(): void {
  let self = this;
  this.texture = this.game.add.renderTexture(this.game.width, this.game.height);
  this.game.add.sprite(0, 0, this.texture);

  this.image = this.parentGame.game.make.sprite(0, 0, this.filename);
  this.image.inputEnabled = true;
  this.image.input.useHandCursor = true;
  this.image.events.onInputDown.add(function () {
    if (self.onMouseEvent) {
      self.onMouseEvent();
    }
  });
}

public update(): void {
  this.texture.renderXY(this.image, 0, 0, this.clearBeforeDraw);
}

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...