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

2019/4/9

replaying previous levels while keeping old ones unlocked

ErasedBlade ErasedBlade

2019/4/9

#
Hi im curentlly having issues with my leveling system. I will change the whole code to fix it btw. i am making a level selection screenfor players to be able to select their own levels, rather than making it change for them automaticly when they beat one. i am using a modified version of dampost's level class senario, since i could only study the code, and not run it to see what every bit of code did. here is my code for the leveling system in level 1, and my selection screen. im only ptting in level 1 since it's value only changes with my other levels (its just coppied code addaped to fit teh new level. selection screen
    private void LevelSpawner()
    {
        addObject(new levelButton(Image[0]), 100,135);
        if (level == 1)
        {
            addObject(new levelButton(Image[1]), 250,200);
        }
        
        if (level == 2)
        {
            addObject(new levelButton(Image[2]), 400,135 );
        }
    }
    public void setFields()
    {
        Levels levels = new Levels();
        if (Level1.er1 == 0)
        {
            level = 1;
        }

        if(Level2.er2 == 0)
        {
            level = 2;
        }
    }
level 1
        Levels levels = new Levels();
       //er1 is counting down however many enemy's are remaining for that proticicular level
        if (er1 == 0)
        {  
            level = 1;
            stopped();
            Greenfoot.setWorld(levels);
        }
danpost danpost

2019/4/10

#
With my Levels support class, the main Levels world was only meant to be created once at the very beginning of a run. All other Levels objects were to be from its subclasses. The Levels class itself was intended to create a header world and be a place where all common methods and fields can be maintained (it seems your er# fields might be a candidate for promotion to the Levels class). You may want to create a separate world for the level selection process.
You need to login to post a reply.