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

2018/2/25

How to move actor to another location

delijamiki delijamiki

2018/2/25

#
Hey, im new in Greenfoot and i need help. How to make an actor constantly moving to another location, and then stop here. (Actor coordinates are 600 and 600 and i want it to constantly moving to 600 400) is that possible?
danpost danpost

2018/2/25

#
1
2
3
4
public void act()
{
    if (getY() > 400) setLocation(getX(), getY()-1);
}
The '1' is the speed. It can be replaced another value or with a field name, the field which holds an int value for the speed of the actor.
delijamiki delijamiki

2018/2/25

#
Thanks very much man
You need to login to post a reply.