Hello, I'm fairly new to Greenfoot and Java, and would like to know how to do some pretty specific stuff. Episode 16 of mik's tutes explains a counter, with direct contact from the object eating the enemy. In my game, the object shoots another object, that eats the enemy. Mik's tutorial showed that you need to create something like Rocket rocket = new Rocket(points) for this to work. However, my "Boop" is not spawned in the world, it is spawned in the Rocket class. I don't know how the Rocket class can communicate with the Points class without going through the World, so I will need some help.
Here is the code to summon the Boop :
And I think that's all you need? Please comment if you need more. Thanks! :)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | /** * Firing the bullet. If there is no delay, create a new Boop facing the rotation of the ship. * Reset the delay timer, too. Speed & movement of bullet is in Boop class. */ public void fire() { if (!delay()) { if (Greenfoot.isKeyDown( "space" )) { Actor b00p = new Boop(getRotation()); getWorld().addObject(b00p, getX(), getY()); b00p.setRotation(getRotation()); delayTimer = 20 ; } } } |