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

2015/4/10

Save a variable throughout multiple worlds?

1
2
Super_Hippo Super_Hippo

2015/4/12

#
What is the difference between 'leben' and 'g1Leben'?
Jimbo(Jack&Jim) Jimbo(Jack&Jim)

2015/4/12

#
'leben' is the leben of the Player (PatAmer) 'g1Leben' is the leben of an specific enemy
danpost danpost

2015/4/12

#
danpost wrote...
Maybe the value never changes from three to begin with. Try this and report back:
if(getWorld() instanceof Level1punkt1punkt1 || getWorld() instanceof Level1punkt1punkt2){
    if( this.getY() <= 15){
        World level121 = new Level1punkt2punkt1();
        PatAmer pa121 = (PatAmer)level121.getObjects(PatAmer.class).get(0);
        System.out.println("Value of 'pa121.g1Leben':   "+pa121.g1Leben);
        pa121.g1Leben = g1Leben;
        Greenfoot.setWorld(level121);
    }
}
I had the wrong field. Change line 5 to this:
jackandjim jackandjim

2015/4/12

#
Thank you, it's working!
You need to login to post a reply.
1
2