Jump to content

Collision detection on dynamic generated objects.


Terumi
 Share

Recommended Posts

Hello all, 

 

I'm trying to make a "game" in which you drag sticks from a pool and you position them on the screen.

(I'm basicaly creating a cuisenaire program).

 

The sticks have to be restrained in the underneath tilemap and also cannot overlap with each other.

 

Every stick has a 
sprite.input.enableDrag();
sprite.input.enableSnap(30, 30, true, true);

 

So it can be draggable.

 

Also, I whenever the user drags a stick from the pool, I clone a stick there so he can drag another one later on.

 

How can I instruct phaser to watch for collisions between all sticks?

If I put them on a group, I loose the input.enableDrag on every stick.

If I don't have them on a group, how can I reference them to watch for collisions with each other?

 

Thank you

Link to comment
Share on other sites

Easy solution I can think of is to put sticks in an array and then loop over the array for collision check in the update() function. Be careful to remove killed or unused objects from array (as Phaser won't handle it).

 

It's a shame not to use groups though : are you sure the inputs won't work if you do so?

 

Performance-wise it shouldn't change anything, I'm pretty sure in the end Phaser.groups are iterated over for collision checks.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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