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

2012/8/18

Random Movement

WatchPatronus WatchPatronus

2012/8/18

#
I have a scenario with this code: import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class enemy here. * * @author (your name) * @version (a version number or a date) */ public class enemy extends Actor { /** * Act - do whatever the enemy wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act () { move(4); } public void moveAround () { move(4); turn(Greenfoot.getRandomNumber(90)); } } but my character is not turning but going in a straight line... what have I done wrong? Thanks for your help WatchPatronus
danpost danpost

2012/8/18

#
You have the method 'moveAround', but it is not being called.
WatchPatronus WatchPatronus

2012/8/18

#
danpost wrote...
You have the method 'moveAround', but it is not being called.
thanks how do I do that?
danpost danpost

2012/8/18

#
Change your 'act' method to this:
public void act()
{
    moveAround();
}
WatchPatronus WatchPatronus

2012/8/18

#
danpost wrote...
Change your 'act' method to this:
public void act()
{
    moveAround();
}
Thanks very much :-)
You need to login to post a reply.