Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (753)
Games in Android Showcase (228)
games submitted by our members
Games in WIP (842)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  [Libgdx] setting the stage Ydown  (Read 1484 times)
0 Members and 1 Guest are viewing this topic.
Offline SonicPixelation

Senior Newbie

« Posted 2014-04-15 18:50:14 »

I have been working with scene2d.ui stage

this is the stage initialization
OrthographicCamera cam = new OrthographicCamera();
ScreenViewport SV = new ScreenViewport(cam);
stage = new Stage(SV);

the reason I have cam.setToOrtho(true);
is because I want the 0,0 to be up in the top left

the text input works if it is given focus at first
but I can not click on it to give it focus

Offline T1663R

Junior Devvie

Medals: 2

« Reply #1 - Posted 2014-04-15 20:29:07 »


so the class youve got that in extends stage ?
or do you create a stage in your class ?
cause youve got to consider, a stage got its own camera and spritebatch.
you can get them with :
Offline SonicPixelation

Senior Newbie

« Reply #2 - Posted 2014-04-16 02:14:26 »

I am just using the default Stage using the screenViewport and pass a new orthographic camera with ydown set. the problem I am having is it seems like the bounding box for the buttons and text fields are not matching up.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Grunnt

JGO Kernel

Medals: 143
Projects: 8
Exp: 5 years

Complex != complicated

« Reply #3 - Posted 2014-04-16 09:18:28 »

I suppose that the Stage should also know you are rendering things upside down? If you flip the rendering but not the input coordinates then clicks are registered upside down. You should tell the Stage that you are using Y-down coordinates.

Here's an example that does what you want (I think):

Offline SonicPixelation

Senior Newbie

« Reply #4 - Posted 2014-04-16 14:25:49 »

ah yes I have come across this so many times it is becoming annoying, in the current version of Libgdx the Stage class has changed since this.

in the old one what you would do would be

Stage stage = new Stage(Width,Height,true);

where Width and Height would be your screen size

but now stage only takes as a parameter the class Viewport

and neither it nor its children classes take the same parameters as the old stage
Pages: [1]
  ignore  |  Print  

ivj94 (584 views)
2018-03-24 14:47:39

ivj94 (48 views)
2018-03-24 14:46:31

ivj94 (382 views)
2018-03-24 14:43:53

Solater (62 views)
2018-03-17 05:04:08

nelsongames (109 views)
2018-03-05 17:56:34

Gornova (159 views)
2018-03-02 22:15:33

buddyBro (702 views)
2018-02-28 16:59:18

buddyBro (92 views)
2018-02-28 16:45:17

xxMrPHDxx (493 views)
2017-12-31 17:17:51

xxMrPHDxx (733 views)
2017-12-31 17:15:51
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!