I need help making a finish line for my game. I want it to move it down like all my other actors are doing except at a certain time and then when the car passes through the finish line, it moves into the next level.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class FinishLine here. * * @author (your name) * @version (a version number or a date) */ public class FinishLine extends Actor { /** * Act - do whatever the FinishLine wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { if (isTouching(FinishLine. class )) { Greenfoot.setWorld( new Level2()); } } } |
1 2 3 4 | if (Greenfoot.getRandomNumber( 100 ) < 1 ) { addObject( new FinishLine(), Greenfoot.getRandomNumber( 1 )+ 300 , 0 ); } |
1 | if (Greenfoot.getRandomNumber( 100 ) < 1 && getObjects(FinishLine. class ).isEmpty()) |