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

2015/2/27

Can anyone help add comments to these lines?

ValeroDeniro ValeroDeniro

2015/2/27

#
nn
danpost danpost

2015/2/27

#
If you are using Greenfoot 2.4.x, then the class you had here could be re-written as follows:
import greenfoot.*;

public class Dangers extends Actor
{
    private static final int WALKING_SPEED = 2; // or whatever value

    public void move()
    {
        move(WALKING_SPEED);
    }
}
There was nothing in the constructor or the act method and all the other methods are now included in the Actor class. Dangers.turn(int) : Actor.turn(int) Dangers.canSee(class) : Actor.isTouching(class) Dangers.eat(class) : Actor.removeTouching(class) Dangers.atWorldEdge() : Actor.isAtEdge() Also, notice that 'Actor.move(int)' simplifies the code in the only method left. Go to the Documentation page for link to Greenfoot API, then select the Actor class for explanations of these methods.
You need to login to post a reply.