Jump to content

Overlap Between a Group and Sprite with Alpha


Recommended Posts

Hello everyone,



I'm supposed to have an interactive christmas tree, kinda like a greeting card. This is just meant for me to practice Phaser.



I've been having issues with a group containing sprites, that are supposed to represent the ornaments of the tree, and detecting an overlap (detect) with a .png sprite containing alpha information to kill off the ornaments if it touches the area -- I'm using Arcade Physics.

The general logic is that if I can get the ornamental objects to be killed off from the interaction of the sprite (aka mask-like object) , I can have randomly generated sprites every refresh, apparently existing inside of the tree.


The funny thing is that the overlap() works if I use a 'mask-like' sprite that is the shape of the tree to kill off the ornaments, except that I want it the other way around -- I want the ornaments to exist within the area of the tree and be killed off outside of it. When I do go about it, the other way around, I use a mask-like sprite taking up the whole canvas except a hole where the tree is, yet the whole group disappears.


It seems like it has to do with the bounding boxes of my mask-like objects. For the first case, The bounding box is smaller, in the second the bounding box is larger. What I'm looking for is a pixel-perfect solution.


I used bitmapData() and its masking method but that didn't work either. Does this have to do with the physics engine in how it calculates bounding boxes?

If there's a workaround that would be of great help. Thanks. I hope this was clear.

Link to comment
Share on other sites


  • Recently Browsing   0 members

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