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


1 | lev = level; |
1 2 3 4 5 6 7 8 9 10 | if (level == 1 ) { Level1 level1 = (Level1) getWorld(); level1.reanimateSnowman(); } else if (level == 2 ) { . . . |
1 2 3 4 5 6 7 8 9 10 11 12 | 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(); } } |
1 2 3 4 5 6 7 8 | public void fall() { setLocation ( getX(), getY() + yGeschwindigkeit); yGeschwindigkeit = yGeschwindigkeit + ORTSFAKTOR; //darf nicht zu hoch werden! if (yGeschwindigkeit > 30 ) { yGeschwindigkeit = 30 ; } } |
1 | snowman.executeAnyMethodIWant; |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | // 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 ); } |
1 | if (getWorld() != null ) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | // 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" ); } |
1 2 | Snowman snowman=(Snowman) snowmanHitten(); snowman.anyPrivateMethod(); |
1 2 3 4 5 | // change your 'Snowman' constructor to public snowman() { setImage( "Schnee.png" ); } |
1 2 3 4 5 | if (level > 0 ) { createConters(); createHearts(); } |