I have a few body in nape one is a loop of 'baddies' the other is a single 'hero' I call my updateGraphics function but how to I taget the hero within this function, I have tried hero.userData.graphic.x but it passes in an array of bodies, is there any way to taget my hero body by id or name?
hero = new Body(BodyType.DYNAMIC);
badguy = new Body(BodyType.DYNAMIC, new Vec2(Math.random()*1280, -100)) // loops to generate lots;
private function updateGraphics(b:Body):void {
b.userData.graphic.x = b.position.x;
b.userData.graphic.y = b.position.y;
}
Why do you need to target 'hero' inside of that function? Why not just call it 'on' hero:
updateGraphics(hero);