Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (536)
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 287 times)
0 Members and 1 Guest are viewing this topic.
Offline SonicPixelation

Senior Newbie





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

I have been working with scene2d.ui stage


this is the stage initialization
1  
2  
3  
4  
5  
6  
OrthographicCamera cam = new OrthographicCamera();
cam.setToOrtho(true);
           
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 Member


Medals: 2



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

hey

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 :
1  
2  
this.getCamera().do_fance_stuff_here();
this.getSpriteBatch()do_fance_stuff_here()
Offline SonicPixelation

Senior Newbie





« Reply #2 - Posted 2014-04-16 04: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 Wizard


Medals: 66
Projects: 8
Exp: 5 years


Complex != complicated


« Reply #3 - Posted 2014-04-16 11: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):
http://libgdx.googlecode.com/svn/trunk/tests/gdx-tests/src/com/badlogic/gdx/tests/YDownTest.java

Offline SonicPixelation

Senior Newbie





« Reply #4 - Posted 2014-04-16 16: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

1  
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

http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/utils/viewport/Viewport.html

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

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

CogWheelz (13 views)
2014-07-30 21:08:39

Riven (21 views)
2014-07-29 18:09:19

Riven (14 views)
2014-07-29 18:08:52

Dwinin (12 views)
2014-07-29 10:59:34

E.R. Fleming (32 views)
2014-07-29 03:07:13

E.R. Fleming (12 views)
2014-07-29 03:06:25

pw (42 views)
2014-07-24 01:59:36

Riven (42 views)
2014-07-23 21:16:32

Riven (29 views)
2014-07-23 21:07:15

Riven (30 views)
2014-07-23 20:56:16
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org 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‑gaming.org
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!