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.
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()); } } }
if (Greenfoot.getRandomNumber(100) < 1) { addObject(new FinishLine(), Greenfoot.getRandomNumber(1)+300, 0); }
if (Greenfoot.getRandomNumber(100) < 1 && getObjects(FinishLine.class).isEmpty())