Jump to content

Get reference a child in a group+collision+Arcade system


Recommended Posts

Hello all!


First. excuse me for my english.


I need to get a reference to child of a group, this in the collide function of Arcade system.



function update(){      collide(spritePlayer, groupPlatforms, collideCallback, processCallback, callbackContext);}I will think do some this:function collideCallback(){       //the problem is  I have no functions to retrieve the child of the groupPlatforms (I have getAt(index) and getIndex(child) for example)}

Any help is appreciated.


Link to comment
Share on other sites

the solution is simple ;)

function collideCallback(_player, _groupPlatforms){     var yourChild = groupPlatforms.getAt(number);}

the _groupPlatforms refers to groupPlatforms and getAt "returns The child that was found at the given index. If the index was out of bounds then this will return -1."

All you need to know on which position your child is.

number => child position in Array (example 0)

Link to comment
Share on other sites

Thanks Sam,


But, the problem is that I don't know the index of the child. 


Is possible obtain a reference to child in a collision, without know the index?




Edit: Here, the solution (found in the forum):




Thanks all,

Link to comment
Share on other sites

yeah that's simply :

function collideCallback(_player, _collidingChild){    }

my bad, you can just put the reference in, and the system will detect the collision of the child of that group that collides.

Link to comment
Share on other sites


  • Recently Browsing   0 members

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