A new version of this scenario was uploaded on Mon Sep 29 12:39:33 UTC 2014
This version is a recent update to the previous which lacked some needed features. One of which is the added alien ships. Also some bug fixes. Shooting alien ships will be in the next update.
It is a Scenario modeled after the Scenario "Space Bound".
It will be updated and new features are sure to be added.
Please feel free to use my source codes in your own game!
Please comment!
A new version of this scenario was uploaded on Mon Oct 06 19:05:50 UTC 2014
-Menu spelling and bug fixes
-Graphical character background is no longer visible during gameplay
-New control menu graphics
I have a question. On the Gameover screen, how do I get the score counter to carry over from the main Space world to the Gameover screen without resetting to "0"?
You can pass it using 'new Gameover(int)' (you will need to adjust your constructor declaration statement to accept the int value) or you can 'pass' it after creating the Gameover world:
[code]Gameover go = new Gameover();
go.getBackground().drawImage(new GreenfootImage("Final score: "+score, 36, null, null));
Greenfoot.setWorld(go);[/code]
I forgot to add the location coordinates to draw the image in the 'drawImage' line; also, the colors ('null' values in the example) can be replaced with actual colors. The example was just one possible way of adding the final score into the Gameover world.
Danpost I am still having issues with the code you gave me. To give you a little more input on the way the score counter code looks, its like this, only its on a different world. But im trying to pass the same code to the Gameover world. here is the score counter code on the main Space world:
[code]private void addAsteroids(int count)
{
for(int i = 0; i < count; i++)
{
int x = Greenfoot.getRandomNumber(getWidth()/2);
int y = Greenfoot.getRandomNumber(getHeight()/2);
addObject(new Asteroid(), x, y);
}
}
private void addUFOs(int count)
{
for(int i = 0; i < count; i++)
{
int x = Greenfoot.getRandomNumber(getWidth()/2);
int y = Greenfoot.getRandomNumber(getHeight()/2);
addObject(new Asteroid(), x, y);
}
}[/code]
The code for the Counter class is the code for the Counter class regardless of the active World. You cannot 'pass' code. All code belongs to the class that it is found in, and to no other. The only things you can pass are values and objects (what is actually passed, where 'objects' are concerned, is the address in memory where the data for the object (an instance created from a class) is located.
The code for the Counter class is not what you need to deal with for you issue. It is the code that defines, creates, and works with the object created from the class that is important, here.
The last statement should include the code where you are trying to pass the score to the Gameover world. When supplying code, also include what class the code is in and how it relates to the World or Actor class.
2014/10/10
2014/10/10
2014/10/10
2014/10/10
2014/10/24
2014/10/24
2014/10/24
2014/10/24
2014/10/24
2014/10/24
2014/10/24