This site requires JavaScript, please enable it in your browser!
Greenfoot back
-nic-
-nic- wrote ...

2012/4/8

how would you find what direction a sprite is ??

-nic- -nic-

2012/4/8

#
how would you find what direction a object is looking and then when you add another object it looks the same way ????
SPower SPower

2012/4/8

#
Add an instance variable to your world:
private int userRotation;
Then, add the act() method to your world:
public void act()
{
if (user != null) {
    userRotation = user.getRotation();
}
}
For this you need an instance variable of your character of the user. Then, you need the 2nd object acces this variable, so in your world, you need to add this method:
public int getUserRotation()
{
return userRotation;
}
Now your object can acces this variable, and you can use the setRotation(int rotation) to set its rotation to that variable. I hope this helps.
-nic- -nic-

2012/4/8

#
thanks:{)
SPower SPower

2012/4/8

#
You're welcome
You need to login to post a reply.