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

2017/4/28

I need a finish line

Student3111 Student3111

2017/4/28

#
I am currently struggling to make it so that when a car (either the player car or opponent) gets to 2 different finish lines for each opponent, an image will pop up with either 'winner' or 'you lose'. this would then take them to the next level.
kursatA kursatA

2017/4/28

#
thats such an interesting question
RustuMan RustuMan

2017/5/4

#
kursatA wrote...
thats such an interesting question
Yeah bro. I need that also.
danpost danpost

2017/5/4

#
Something like the following should work in the car class(es):
// instance field
private Actor finishActor;

// in act method
if (finishActor == null && isTouching(FinishLine.class))
{
    finishActor = getWorld().getObjects(Winner.class).isEmpty() ? new Winner() : new YouLose();
    addObject(finishActor, getX(), getY()-50);
}
An int timer field in the YouLose class can be used to delay going to the next level.
You need to login to post a reply.