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

2013/9/20

Text Boxes

DemonicButterflies DemonicButterflies

2013/9/20

#
I wanted to make a game where when the character hits an object a text box will show up. After it shows up I want to be able to close the text so that the character can interact with another object or move around without the text there. Any help? p.s. Uh, I think you have a fan danpost... Do you know DanPostLover?
DemonicButterflies DemonicButterflies

2013/9/20

#
Uhm, I have a project due tomorrow and it's a test grade and I was hoping I could finish it tonight... I only need this text box problem fixed. Anyone please help?
DemonicButterflies DemonicButterflies

2013/9/20

#
No, Yes? Okay...
danpost danpost

2013/9/20

#
What code do you have so far? and what condition needs satisfied for the text to be removed?
DemonicButterflies DemonicButterflies

2013/9/20

#
I didn't know where to start with the coding so I don't really have anything to show. I would like for my character to touch an object in the world and have a textbox pop up then have you click okay to close it.
danpost danpost

2013/9/20

#
For that, you will need two actor classes -- one for displaying the message and the other for the button to click on that says 'OK'. You can create these classes separately; but I would code the OKButton class inside the Message class and use the 'addedToWorld(World)' method to have the message object create its own OK button. However you decide to arrange the classes, you will still need to pass the message object on to the button class, so the button can remove the message from the world before removing itself when clicked on.
DemonicButterflies DemonicButterflies

2013/9/20

#
Thanks helpful <3 p.s. My friend DanPostLover says hi. :p
GreenHouse GreenHouse

2013/9/20

#
Message dialog:
import javax.swing.JOptionPane;
import greenfoot.core.WorldHandler;

//

JOptionPane.showMessageDialog(
    WorldHandler.getInstance().getWorldCanvas(),
    "Hey whats up!",
    "Information",
    JOptionPane.INFORMATION_MESSAGE);
This will stop the user from interacting until the box gets closed.
You need to login to post a reply.