Questions tagged [scene2d]

Scene2d is a 2D scene graph for building applications and UIs using a hierarchy of "actors". Integrated in libGDX.

Scene2d is a 2D scene graph for building applications and UIs using a hierarchy of actors. Integrated in . It provides the following features:

  • Rotation and scale of a group is applied to all child actors. Child actors always work in their own coordinate system, parent transformations are applied transparently.

  • Simplified 2D drawing via SpriteBatch. Each actor draws in its own un-rotated and unscaled coordinate system where 0,0 is the bottom left corner of the actor.

  • Hit detection of rotated and scaled actors. Each actor determines if it is hit using its own un-rotated and unscaled coordinate system.

  • Routing of input and other events to the appropriate actor. The event system is flexible, enabling parent actors to handle events before or after children.

  • Action system for easy manipulation of actors over time. Actions can be chained and combined for complex effects.

511 questions
31
votes
3 answers

How to create a button in Libgdx?

I want to create a button that changes when the user hovers it, or clicking it. I created the following variable Button buttonPlay = new Button(); I don't know what to do now, how to load the images? How to write text into the button? How to…
julian
  • 4,188
  • 9
  • 38
  • 58
14
votes
2 answers

Putting Freetypefont into libgdx skin

In my uiskin.json I have this com.badlogic.gdx.graphics.g2d.BitmapFont: { default-font: { file: text/default.fnt } } This is fine for when I have the default.fnt in my text folder in the assets folder... However I want to use a Freetypefont. How do…
Seanoseanohay
  • 331
  • 3
  • 18
12
votes
3 answers

libgdx - how to add background image in stage?

I am learning libgdx but i am stuck at a point.. I have added a button in my stage , now i want to add a image in the stage so that the image looks as the background image to the button.i mean to say that the button should lie on the image. I have…
rahul_raj
  • 275
  • 2
  • 3
  • 9
11
votes
3 answers

How to draw Button class in libgdx

I know that libgdx has this Button class that seems so easy to use, but I wonder why the draw method is set protected? In that case, how should I draw the button? Scene2d Button
Fugogugo
  • 4,160
  • 10
  • 34
  • 45
11
votes
1 answer

When to use ShapeRenderer, Mesh + SpriteBatch, Box2D and Scene2D in Libgdx?

I'm new in Android Game Development and after I started with libgdx ShapeRenderer and did a little more search, I became confused if I started with the right foot. So, what I really would like to know is when should I use ShapeRenderer, Mesh +…
Cristiano Santos
  • 2,055
  • 2
  • 33
  • 47
10
votes
3 answers

How do I make a ProgressBar work in LibGDX?

I'm trying to understand how to use a ProgressBar in LibGDX. I have created the bar but I don't know how to make it works. I want to duplicate the knob in order to fill the bar(background line) in 60 seconds. I know how to manage about the time,…
adrianoubk
  • 215
  • 1
  • 3
  • 11
9
votes
2 answers

Libgdx label rotation

Is it not possible to rotate a Label? It seems the API has that function but it doesn't seems to work? Are there anymore ways to rotate text? Label nameLabel = new Label( "Test", skin); nameLabel.setRotation( 90 ); stage.addActor( nameLabel );
pakito
  • 391
  • 2
  • 3
  • 15
9
votes
2 answers

Align text left in libgdx TextButton

is there a way to align the text in a textbutton to left (or right) instead of center? I'v looked for it, but I cant seem to find it. Is it something that you can do with a .json skin file, and if so, how? Thanks, if I was unprecise please let me…
Jolly
  • 389
  • 2
  • 12
9
votes
1 answer

Why Libgdx's Table does not accept scale action?

I'm using scene2d in libgdx library for creating some UI in my game. I used a Table and I want to take some scaling action when user touches to make a button touching sense. When I used any other "Actor" types like Group and giving it a scale…
Aliaaa
  • 1,358
  • 2
  • 13
  • 30
8
votes
3 answers

Using libgdx, how can I add both text and images to a ScrollPane?

Here is a code snippet. itemList = new List(skin, "ariel.32.white"); String[] tmpInv = new String[b+1]; tmpInv[0] = ""; a++; for (Entry entry : inventoryItems.entrySet()) { tmpInv[a] = entry.getKey(); a++; …
Sym
  • 177
  • 1
  • 9
8
votes
2 answers

overriding drawing order scene2D's stage

You are given a complex Scene2D graph in libgdx with several Group's and Actor's. You want the user to select some Actors and draw those at the end so they appear focussed on top of any other Actors. I would like to iterate over the Stage twice.…
Vjeetje
  • 4,914
  • 3
  • 31
  • 52
8
votes
2 answers

Proper using of scene2d's Stage in a game with a huge world

If the whole "game world" is thousands of times wider than a viewport, and if I want to use scene2d to manage game objects as Actors, should I create Stage object as wide as the whole world, or should the Stage be some area around current viewport…
gvlasov
  • 14,781
  • 17
  • 61
  • 99
8
votes
2 answers

Using scene2d.ui with libgdx: where does the skin come from?

I've read about libgdx's scene2d features, including the UI elements, but I can't get them to work. They all seem to use a skin object, how do I create one? I've gone through the nice tutorial that creates a simple libgdx game catching raindrops in…
Don Kirkby
  • 41,771
  • 21
  • 173
  • 252
8
votes
2 answers

LibGDX initialize Drawable

This is a Question for those who are familiar with the new LibGDX 0.98. I'm not quite sure, how to use a Drawable in the Scene2d package. My current code for using a ".png" as a Background for various classes looks like this: new…
Xerusial
  • 385
  • 1
  • 3
  • 13
7
votes
4 answers

Libgdx | Scene2d | Set background color of table?

I am creating a menu (like the one is flappy bird, when you die it pops up over the play screen). I created a class that extends table, and I want to set the background of the table to white. Is there a way to do this?
J Doe
  • 323
  • 2
  • 12
1
2 3
34 35