Alright, here's the code of the title screen, hope that helps :).
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
public class Background0 extends World
{
Flecha flecha = new Flecha();
private int opcion = 0;
GreenfootSound backgroundMusic = new GreenfootSound("Intro.wav");
public Background0()
{
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
super(900, 500, 1);
backgroundMusic.playLoop();
prepararMundo();
prepare();
}
private void prepararMundo(){
addObject(new Fernan(), 263,121);
addObject(new Start(),700,170);
addObject(new SalirMenu(),700,250);
addObject(flecha,614,170);
}
public void act(){
if (Greenfoot.isKeyDown("UP") && opcion!=0) {opcion++;}
if (Greenfoot.isKeyDown("DOWN") && opcion!=1) {opcion--;}
if (opcion>=2) opcion = 0;
if (opcion<0) opcion = 1;
flecha.setLocation(614, 170 + (opcion*95));
if (Greenfoot.isKeyDown("Space") || Greenfoot.isKeyDown("Enter")){
switch(opcion){
case 0:
backgroundMusic.stop();
Greenfoot.delay(20);
Greenfoot.setWorld(new BackgroudLvls());
break;
case 1:
Greenfoot.stop();
break;
}
}
}
/**
* Prepare the world for the start of the program.
* That is: create the initial objects and add them to the world.
*/
private void prepare()
{
}
}
That doesn't happen to me - Fernand always appears at the same spot whenever I restart the game. What I have seen though is that, when you die and restart the game, Fernand spawns without lives. That's an odd bug. What I do in that case is to restart this very website.
Hope that helps. If not, please let me know so that I share the code.
2023/7/20
Fernand the Kinght
2023/7/19
Fernand the Kinght
2023/7/19
Fernand the Kinght