I have published the source code of my game. You can have a look at it ;)


lev = level;
if (level == 1) { Level1 level1 = (Level1) getWorld(); level1.reanimateSnowman(); } else if (level == 2) { . . .
public void checkDeath() { if (getY() == getWorld().getHeight() - 1) //This is the new part. it's written before it executes the destructor. { getWorld().removeObject(this); } if (getWorld() == null) { leben--; reanimation(); } }
public void fall() { setLocation ( getX(), getY() + yGeschwindigkeit); yGeschwindigkeit = yGeschwindigkeit + ORTSFAKTOR; //darf nicht zu hoch werden! if (yGeschwindigkeit > 30) { yGeschwindigkeit = 30; } }
snowman.executeAnyMethodIWant;
// remove line 12, which is Actor snowman; // remove this (line 12) // change 'killSnowman' method to private void killSnowman() { Snowman snowman=(Snowman)snowmanHitten(); if(snowman != null) { getWorld().removeObject(snowman); snowman.checkDeath(); getWorld().removeObject(this); } } // change the last line in your 'act' from checkSelbstzerstoerung(); // to if(getWorld() != null)checkSelbstzerstoerung(); // change 'snowmanHitten' method to private Object snowmanHitten() { return getOneIntersectingObject(Snowman.class); }
if(getWorld() != null)
// IN YOU SNOWMAN CLASS // add the following method public void addedToWorld(World world) { createCounters(); createHearts(); } // remove those same lines from each 'if'block in 'checkNextLevel' // change your 'Snowman' constructor to public snowman() { setImage("Schnee.png"); }
Snowman snowman=(Snowman) snowmanHitten(); snowman.anyPrivateMethod();
// change your 'Snowman' constructor to public snowman() { setImage("Schnee.png"); }
if (level > 0) { createConters(); createHearts(); }