Hello everyone. Im new at Greenfoot and i want to make a simple project. I want my actor, while he is "walking" he has to make a Track --> He has to place some Balls (name Track) , so when he touches the Balls he will turn .Like he is always going straight and my mission is that he has to touch the point at the Center (name Ball). is At edge is very helpful, but i kneed touching the balls (object) too but im not able to create them. The location where the balls will be created must be the same that the Actor is walking. Pls look at my script. I know im really bad at this, but hey im new at this.
World:
private void prepare()
{
Ball ball = new Ball();
addObject(ball,277,257);
ball.setLocation(300,300);
RobotMaBoi robotMaBoi = new RobotMaBoi();
addObject(robotMaBoi,0,600);
robotMaBoi.setLocation(65,557);
}
Actor:
public void act()
{
if (isAtEdge()){;move(-2); turn (270); move(1);}
else{move(1);
timer ++; if(timer == 4){ X = getX(); Y = getY();} if (timer == 5){
timer = 0;}}
}
Track:
public class Track extends RobotMaBoi
{
/**
* Act - do whatever the Track wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
if(timer == 5){Track a = new Track(); getWorld().addObject(a, 200, 400);
setLocation(X,Y);}
}
}