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

2019/4/10

How do I cite the move() method on an Actor

compsci9001 compsci9001

2019/4/10

#
I just downloaded Greenfoot and I don't know how to do this.
danpost danpost

2019/4/10

#
If you look in the Actor class API documentation on the method move, you will find it requires an int parameter for how far to move (in cells). This method also requires that the actor moving be in a world (makes no sense, otherwise, and will throw an IllegalStateException error).
compsci9001 compsci9001

2019/4/10

#
/**
     * Move one step forward.
     */
    public void move()
    {
        move(1);
    }
In this part could I just change the int to a different number for the wombat to move a different amount of spaces on the grid?
danpost danpost

2019/4/10

#
compsci9001 wrote...
<< Code Omitted >> In this part could I just change the int to a different number for the wombat to move a different amount of spaces on the grid?
Try it. Use the Act button for testing. (I presume that the method is being called from the act method).
You need to login to post a reply.