This site requires JavaScript, please enable it in your browser!
Greenfoot back
Mint_Greenie
Mint_Greenie wrote ...

2014/6/12

Open a .jar in Green foot?

Mint_Greenie Mint_Greenie

2014/6/12

#
Hello, I've created a Paint application. I want it to have a save button that will over ride a file in my games library called default.jpg. Then I want the paint app I created to open the game (Flappy Bird). I want to do this so that default.jpg can be whatever the user drew. Is it possible to do this and how? Thanks, Arman
CooliMC CooliMC

2014/6/12

#
I think thats not Possible but when you add this Paint application as a class in the Flappy Bird Game before start the game you could save the new picture as A GreenfootImage in the world and load it from there during the game. I hope i could help you
Mint_Greenie Mint_Greenie

2014/6/12

#
Thanks @CooliMC! Your explanation helped me! Is there a way I can change the first world that appears in the game.
CooliMC CooliMC

2014/6/12

#
if you want to remove all the objects and paint then a new world for example called flappybird you should write a methode in the world called secondworld() { removeObjects(getObjects(null)); } and place the objects you want to add new after the ; in the methode and when you want to start the second wolrd you only must call this methode, Hope i could help you :D
mriley6079 mriley6079

2014/6/12

#
Not quite sure of what you want me to do?
CooliMC CooliMC

2014/6/12

#
add a methode to your wolrd:
 secondworld() 
{ 
removeObjects(getObjects(null));
ADD YOUR CODE HERE
 }
and where i write add code you could write for example addObject or setImage or something like that , because with this methode you get a new and clear screen
Mint_Greenie Mint_Greenie

2014/6/13

#
@CooliMC: Wouldn't it be easier to switch the games world class? I have basically imported some of the code from the paint app and the flappy bird app into two worlds. I plan to do the order below when the user hits the play button on the drawing world: 1.Open new world (FlappyBird) 2. Add the users image that was drawn to FlappyBird world. 3. Allow the users to start the game. Is it possible?
CooliMC CooliMC

2014/6/13

#
Yes thats also possible but the order must be: when you want to get the secod world: 1.draw second world 2. in second world constucter:
public class Secondworldname extends World
{
GreenfootImage DRAWNIMAGE;
public Secondworldname
{ 
Firstworldname bg = (Firstworldname) getWorld();
this.DRAWNIMAGE=bg.DRAWNIMAGE
}
...
}
3.delete the FIRSTWORLD I hope you understand it
danpost danpost

2014/6/13

#
You do not have to save the image to a file -- it is a GreenfootImage object referenced by a field (I will name the field 'image').. All you need to do is to create a reference to the new world when you create it. If 'GameWorld' was the name of your game world, then:
GameWorld gw = new GameWorld();
creates the reference in 'gw'. From there you can execute method and access fields in the new world using the dot operator on 'gw' (for example 'gw.setBackground(image);' or 'gw.getPlayer().setImage(image);' or 'gw.player.setImage(image);'). After altering the world in the way you want, you can then make it the active world with 'Greenfoot.setWorld(gw);'.
You need to login to post a reply.