I move my actor(Human) right 10 pixel but the gun does not follow the human. Please give me the code that make the gun follow the another actor. Thank you.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | //in your human class: private Gun gun; public Human() { gun = new Gun(); } public void addedToWorld(World world) { getWorld().addObject(gun, getX(), getY()); //maybe you have to use other coordinates here; } public void setLocation( int x, int y) { super .setLocation(x, y); gun.setLocation(x, y); //again maybe some other coordinates; } |