Inside the "Ship" Class
Anyway, what I want to do is then in the "PowerUP" class change the value from 1 to 2, 3, 4,... According to how many PowerUPs I've already gathered.
I've tried this:
but Greenfoot crashes in " int PUP = ((Ship)getWorld().getObjects(Ship.class).get(0)).PUP++;" whenever I try to "catch" a PowerUP
1 | public int PUP = 1 ; |
1 2 3 4 5 6 7 | if (Greenfoot.isKeyDown( "space" )) { if (PUP == 1 ) { Will shoot only 1 bullet at a time } if (PUP == 2 ) { Will shoot 3 bullets at a time } } |
1 2 3 4 5 6 7 8 | Actor MiniPowerUP = getOneIntersectingObject(Ship. class ); if (MiniPowerUP != null ) { Greenfoot.playSound( "explosion.wav" ); ((AsteroidWorld)(getWorld())).score.add( 50 ); getWorld().removeObject( this ); int PUP = ((Ship)getWorld().getObjects(Ship. class ).get( 0 )).PUP++; } |