lean / phaser-es6-webpack

A bootstrap project for create games with Phaser + ES6 + Webpack.
MIT License
1.28k stars 314 forks source link

Mouse over a button error #19

Closed bthachdev closed 7 years ago

bthachdev commented 7 years ago

I get this error when move mouse over a button (using atlasJSONHash to load a spritesheet);

Uncaught TypeError: Cannot read property 'style' of undefined at Phaser.InputHandler._pointerOutHandler (phaser-split.js:19444) at Phaser.Pointer.swapTarget (phaser-split.js:17616) at Phaser.Pointer.processInteractiveObjects (phaser-split.js:17588) at Phaser.Pointer.move (phaser-split.js:17507) at Phaser.MSPointer.onPointerMove (phaser-split.js:16194) at HTMLCanvasElement._onMSPointerMove (phaser-split.js:16080)

Note, it's not happen if I created a button using game.add.button

let button = this.game.add.button(50, 50, 'buttons', actionOnClick, this, 'button-01', 'button-02.png', 'button-03.png');

But if I create a class inherit from Phaser.Button, that bug happens

export default class extends Phaser.Button {

  constructor ({ game, x, y, asset, callback, callbackContext, overFrame, outFrame, downFrame, upFrame}) {
    super(game, x, y, asset, callback, callbackContext, overFrame, outFrame, downFrame, upFrame)

    this.game = game
    this.anchor.setTo(0.5)
  }
}
bthachdev commented 7 years ago

I solved it, when create a new instance, I change from new Button(this, ...) to new Button(this.game, ...) You can close this thread.