RSkene

Pointer Events on Sprite not Dispatched

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!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Recently Browsing   0 members

    No registered users viewing this page.