Jump to content

Interactive / buttonMode just not working for me


Recommended Posts


So i'm making a game and I am having no luck after 3 hours of trying to get a simple mouse click on a container or graphic. Below are snippets of code related to the issue:

At the top:

import * as PIXI from 'pixi.js';
gameInstance = PIXI.autoDetectRenderer({
        width: gameWidth,
        height: gameHeight,
        antialias: true,
        backgroundColor: 0x81a832,
        resolution: window.devicePixelRatio || 1

I make a master container for the game

gameStage = new PIXI.Container();*

I have several containers, to help keep things ordered

HUDContainer = new PIXI.Container();

Then I draw a bar top and bottom, I see these when I run the game

let graphics = new PIXI.Graphics();
    graphics.interactive = true;
    graphics.buttonMode = true;
    graphics.on('mousedown'function (e) {
        console.log('Mouse clicked');

And then in my animation tick:


But clicking on them does nothing, no errors, no cursor change mousing over them, nothing. Rest of the game works fine, but I can't get simple mouse interaction to work

I've tried applying the interactive + buttonMode to graphics, containers, sprites. All failed


Any help greatly appreciated, i've hit a wall


Link to comment
Share on other sites

5 hours ago, ivan.popelyshev said:

Hello and Welcome to the forums!

It should work.

It sounds like HTML/CSS issue. Are you sure there's nothing above your canvas blocking clicks?



That was it, the canvas was getting added to the bottom of the document and not in the "gameContainer" container element I created which was above everything else (and the canvas). It behaved the same visually so I didn't notice it until I inspected the Elements



Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

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