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

2016/3/4

Make an object go after another object

Bassusour Bassusour

2016/3/4

#
Hello again. My problem is that I want an object from one class to go after another object from another class. And the turnTowards(); method is really useful for that. However, this method does not accept a class as coordinates. I'd like your response :)
ElNo ElNo

2016/3/4

#
If actor1 should turn towards actor2 you have to use the getX() und getY() methods of actor2. Code for actor1:
turnTowards(actor2.getX(), actor2.getY());
Bassusour Bassusour

2016/3/5

#
Thanks for answering, but your code shows an eror saying: "non-static method getX() cannot be referenced from a static context", and the same goes for the getY() I do not know the problem behind your code, as the getY() and getX() returns an int, which is what I need.
You need to login to post a reply.