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

2017/12/27

Place object relative to window

benja24 benja24

2017/12/27

#
Hello, I need to place an object in the center of the screen, not the center of the world, because my world is bigger than the screen. This object is created (and removed) during the scenario. Any ideas on how to fix this? Thanks in advance, Benjamin
danpost danpost

2017/12/27

#
Why would you create a world that is larger than your screen? That would force the user to bother with moving the window or messing with scrollbars. What type of scenario are you creating? (is it a game or something else) What type of object is being placed (and removed) from the world? Or, maybe you do not actually mean "screen", but possibly "scrolling area" -- just conjecturing.
benja24 benja24

2017/12/27

#
My scenario is a type of strategy game, with a rather large map as world, when the user clicks I want to be able to open a menu in the middle of the window. Because it isn't a action game I don't think that scrolling is a problem.
danpost danpost

2017/12/27

#
Is the menu like an question with options that must be chosen from? If so, you could create a single World subclass to show the menues and return the response back to the original world. Or, if the project is not to be uploaded on the Greenfoot site, you could use a swing JFrame to show the menu (which should automatically be displayed in the middle of your screen.
xbLank xbLank

2017/12/27

#
danpost wrote...
Is the menu like an question with options that must be chosen from? If so, you could create a single World subclass to show the menues and return the response back to the original world. Or, if the project is not to be uploaded on the Greenfoot site, you could use a swing JFrame to show the menu (which should automatically be displayed in the middle of your screen.
this.
benja24 benja24

2017/12/27

#
The menu shows information, i. e. polpulation and resources (stored as fields in the city that was clicked) and has some buttons to change those fields. I wasn't planning on uploading the project so a JFrame sounds like a interesting solution... Thank you!
You need to login to post a reply.