Reputation: 1937
I am trying to get PixiJS mouse events to fire on an animated sprite.
var sprite = PIXI.extras.AnimatedSprite([] of Texture) // array of textures
sprite.x = 0;
sprite.y = 0;
sprite.interactive = true;
sprite.buttonMode = true;
sprite.on('click', onClick);
sprite.play();
app.stage.addChild(sprite);
function onClick() {
console.log("Clicked.");
}
The sprite correctly appears and is animating, however the click event will not fire. If I change 'click' to 'mousemove' or 'pointermove' it will fire wherever my mouse is on the canvas, even when not over the sprite, which is odd.
Upvotes: 0
Views: 764
Reputation: 1937
I solved the issue, I had a div that was full viewport width/height that blocked the canvas, pretty simple mistake.
After removing the div everything works as expected.
Upvotes: 1