I have an array of players (10) and a ball.
I have a listener on the ball to detect collisions with players and the sidelines, the net etc…
Then I decided i would to give a bit of graphic effect if two players collide. So i’ve added another listener on the players as well. like this:
theball.collision = on\_ball\_collision theball:addEventListener("collision", theball ) for lip = 1,max\_players do players[lip]:addEventListener("collision", on\_player\_collision ) players[lip]:addEventListener("tap",tap\_players) end Runtime:addEventListener("enterFrame",everyframe)
after I added the ‘on_player_collision’ listener I have the two bizarre and unwanted effects:
-
the ‘on_ball_collision’ listener doesnt fire anymore
-
the ‘on_player_collision’ only detects the collisions with the ball, NOT with the other players
-
Note that at this stage the ‘on_player_collision’ does nothing, just print what collides with what.
as soon as I switch the ‘on_player_collision’ listener off the ‘on_ball_collision’ works again.
I read a few forums about collisions and saw Brent answers about “better to use a global on so many objects”.
but 10 is not ‘so many’, is it ?
I have isolated the very same physic objects and listener in a little program (without the enterframe) and it seems to be working fine so i’m confused.
help !
thanks
Ed