Hey,
I am creating a Jump'N'Run Game and i've already managed to make my player change the level. My Player collects Apples. Now I want to program that my player keeps the score of the Apples when he switchs to the next level.
Could you help me?
(I'm sorry that my english isn't the best haha)
Import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
public class Schwein extends Animal
{
public int gegesseneÄpfel = 0;
public void essen()
{
if (isTouching (Apfel.class)) {
removeTouching (Apfel.class);
gegesseneÄpfel = gegesseneÄpfel + 1;
if (gegesseneÄpfel == 5) {
Greenfoot.playSound ("fanfare.wav");
Greenfoot.stop();
}
}
}
public void levelwechseln()
{
if (isAtEdge()) {
if (getWorld() instanceof Level1) {
Greenfoot.setWorld(new Level2());
}
else if (getWorld() instanceof Level2) {
Greenfoot.setWorld(new Level3());
}
else if (getWorld() instanceof Level3) {
Greenfoot.setWorld(new Level4());
}
else if (getWorld() instanceof Level4) {
Greenfoot.setWorld(new Level5());
}
else if (getWorld() instanceof Level5) {
Greenfoot.setWorld(new Level6());
}
else if (getWorld() instanceof Level6) {
Greenfoot.setWorld(new Level7());
}
}
}
}
