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

2019/12/6

Text box

Chase Chase

2019/12/6

#
Hi, In the game I want a text box to pop up that writting in it when ever you click on some actors... I have if(Greenfoot.mouseClicked(this)); but thats it... I'm not sure how to get the rest...
danpost danpost

2019/12/6

#
Chase wrote...
Hi, In the game I want a text box to pop up that writting in it when ever you click on some actors... I have if(Greenfoot.mouseClicked(this)); but thats it... I'm not sure how to get the rest...
Please refer to my Value Display Tutorial scenario.
Chase Chase

2019/12/6

#
sorry, but I still don't understand...
Chase Chase

2019/12/6

#
I tried this if(Greenfoot.mouseClicked(this)) new TextArea("Hello", 400, 400); there are no syntax errors but nothing happens when I click on the actor...
danpost danpost

2019/12/6

#
Chase wrote...
I tried this if(Greenfoot.mouseClicked(this)) new TextArea("Hello", 400, 400); there are no syntax errors but nothing happens when I click on the actor...
Looks like you are creating the actor but not placing it into the world.
Chase Chase

2019/12/7

#
it's in the world... but nothing happens when clicked on. here is all the code in the actor. import greenfoot.*; import java.awt.*; public class Springbot extends Actor { public void act() { if(Greenfoot.mouseClicked(this)) new TextArea("Hello", 400, 400); } }
danpost danpost

2019/12/7

#
danpost wrote...
Looks like you are creating the actor but not placing it into the world.
I was referring to the TextArea object -- not the actors being clicked on (or Springbot object).
Chase Chase

2019/12/7

#
so how can I just add it to an actor instead of making it an actor?
Chase Chase

2019/12/7

#
I see what you are saying it's because of "new" . Is there a way to make this just part of the code or does it have to be an Actor?
danpost danpost

2019/12/7

#
Chase wrote...
so how can I just add it to an actor instead of making it an actor?
What ?? I indicated that you created one. Creating it does not put it in your world, however. You need to add that (created) TextArea object into the world to make it show.
You need to login to post a reply.