Jump to content

Pointer Events on Sprite not Dispatched


RSkene
 Share

Recommended Posts

Hi.

I have been struggling to get an onInputDown event working on a sprite.

I am using phase-ce v2.9.2 (I have tried earlier versions as well with no luck) with webpack for build and within a vuejs application.

Below is code I'm using to test events on sprites but this isn't working.

class ButtonTest extends Phaser.Sprite {

  constructor(game, x, y) {

    super(game, x, y, 'objects', 'd-pad/left');

    this.game.stage.addChild(this);
    this.inputEnabled = true;
    this.events.onInputDown.add(this.down, this);

  }
  down() {
    console.log('down')
  }
  update() {
    if (this.input.pointerOver()) {
      console.log('over')
    }
  }
}

export default ButtonTest;

It must have something to do with my build because I have tried similar code with a different build and it has worked.

The phaser game is only one part of a larger project so I need to continue to use vuejs.

Cheers in advanced for any help!

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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