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

2013/1/17

Turn Towards (Help)

u15ahernandez u15ahernandez

2013/1/17

#
turnTowards public void turnTowards(int x, int y) Turn this actor to face towards a certain location. Parameters: x - The x-coordinate of the cell to turn towards y - The y-coordinate of the cell to turn towards This is the code for turning towards a certain direction. What would I do if Actor_Zombie wanted to turn towards Actor_Surviver? What would it look like for the actor zombie's code? Thanks in advance! c:
davmac davmac

2013/1/17

#
Assuming you have a reference to the Surviver in 'surviver', then: turnTowards(surviver.getX(), surviver.getY());
u15ahernandez u15ahernandez

2013/1/17

#
A reference?
davmac davmac

2013/1/17

#
Yes. A variable referring to the object.
u15ahernandez u15ahernandez

2013/1/17

#
Oh.. Okay. A sort of reference like a scoreboard would have? Thanks c:
You need to login to post a reply.