Jump to content

Click event not registering until using .hitArea


Jammy
 Share

Recommended Posts

Hey guys, I'm wondering if anyone can spare some time to please help me? The issue exists within an existing project so is difficult to debug. I'm hoping people can just suggest anything rather than seeking a specific fix while I continue to debug

1. I create an object and place it on the renderer.

2. Then I attach a function to the "pointerdown" event on that object.

furni.interactive = true;
furni.on('pointerdown', function(){				
	game.ui.showElecFurniInfo(this);
});

3. I then create sprites above it that act like flashing/rotating spot lights

e.g.

light = PIXI.Sprite.fromImage("png/spotlight3.png");
light.width= 64*2;
light.height= 64*3;
light.x = furni.x+44;
light.y = furni.y+10;
light.height = light.height /2;
light.anchor.set(0.5);
light.alpha = 1;
light.rotate = -180
light.blendMode = PIXI.BLEND_MODES.ADD;
game.render.lights.addChild(light);
game.flashingLights.push(light); //This will change the opacity every now and then
game.rotatingLights.push(light); //This will rotate the light every now and then

 

This is where the problem starts. The pointerdown event isn't firing if one of the rotating lights happens to be over where I click. Even though light.interactive is not set, and even explicitly setting it doesn't resolve the issue.

Notes:

  • Removing the lights does fix the issue.
  • Adding the same pointerdown function to the lights fixes the issues but the lights are bigger than the object so it's a crap 'fix'.
  • See test case below
  • In my real code there are multiple containers both above and below these objects which may have click events

Test case outside of the project shows the issue should not occur: 

 

[Some form of fix]

The problem can be fixed with: 

light.hitArea = new PIXI.Rectangle(0, 0, 0, 0);

This just adds to the confusion more to be honest...

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.

Guest
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.

Loading...
 Share

  • Recently Browsing   0 members

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