ForgeableSum Posted December 20, 2014 Share Posted December 20, 2014 So I'm moving sprites across the screen with moveToXY and continually checking the velocity (in the updates function) to see if the sprite makes it to its destination, like so: if ((player.body.speed > 0) && (reachedDestination(player,destination))) { player.body.velocity.x = 0; player.body.velocity.y = 0; } This works fine, until I add the player to a group, and try to call this function on each member of the group: units.addChild(player); units.foreach(function(unit) { if ((unit.body.speed > 0) && (reachedDestination(unit,destination))) { unit.body.velocity.x = 0; unit.body.velocity.y = 0; } }); For some reason, unit.body.speed always shows up undefined. unit.body.velocity.x or y doesn't work either. I'm baffled as to why the function works on a single object but not on multiple. Link to comment Share on other sites More sharing options...
Recommended Posts