My favorites | Sign in
Project Home Downloads Wiki Issues Source
2D-scenegraph implementation for 2D scenes
scenegraph, 2D
Updated Mar 30, 2012 by


(also see Scene2d UI)

"official wiki article":

A 2D-scenegraph implementation for quick creation of 2D scenes.

Update: scene2d was refactored lately. See the changes on Mario's blog:

and lately

Example usage


(some snippets taken from libGDX javadocs)


A Stage is a container for Actors and handles distributing touch events, animating Actors and asking them to render themselves. A Stage is basically a 2D scenegraph with hierarchies of Actors.

Stage has a Camera. This can be used for e.g. zooming and moving the viewport over your scene (also in combination with TweenEngine.


Actors can be put on stage (I like this metaphora).

An Actor is part of a Stage or a Group within a Stage. It has a position, a rectangular size given as width and height, a rotation angle, a scale in x and y and an origin relative to the position which is used for rotation and scaling.

Actors have a "visible" flag that toggles an actor's visibility.

All actor's input methods are public.

Some of Actor's methods:

 public abstract Actor hit (float x, float y);
 public abstract boolean touchDown (float x, float y, int pointer);
 public abstract void touchDragged (float x, float y, int pointer);
 public abstract void touchUp (float x, float y, int pointer);

See the list of available Actors:


A group is an Actor that contains other Actors (also other Groups which are Actors).


An Action is used with an Actor and modifes the Actor's attributes over time.

See the list of available Actions:


An AnimationAction performs a transformation on its target Actor. These transformations physically change the Actor itself.


A base class for composite actions which deals with multiple child Action.


A TemporalAction controls an Action by repeating, delaying etc. the effect of an Action.


An interpolator defines the rate of change of an animation. This allows the basic animation effects (alpha, scale, translate, rotate) to be accelerated, decelerated etc.

See the list of available Interpolators:


Q: How can I move Actors on stage in scene2d?

A1: In your ApplicationListener call ...


stage.act will call all the Actor.act() method in all actors in the stage, which in turn will make sure all Actions are executed.

A2: You could refer to ActionTest in gdx-test project. That's the best practise of Action associated with Actor.

Is anybody listening? Time for some action!

Interaction with Stage elements is possible by registering your Stage as the current InputProcessor. LibGDX framework will then call the element's touch handlers.

You can register a stage as your current input processor like this:


Q: How do the actor´s touch events get called? They have touchable parameter and they implement touchable functions but nothing calls them?!

A: LibGDX framework's native code listens for actual events, that code then calls the input processor that's currently registered (in this case your Stage) the Stage calls it on it's groups, they call it on their actors.

touchDown, for example, gets passed to the root group, which then goes through its children like this:

if (child.hit(point.x, point.y) == null) continue;
 if (child.touchDown(point.x, point.y, pointer)) { ... }

touchDown() will be called on all objects until one of them returns true.

All you need to do is to create a Stage instance and register it with any of these:


Example code for all input events passed directly to the Stage (and nowhere else):

ui = new Stage(800, 480, false);

Then it will pass touch events to it's children (the Groups/Actors). Touch events are passed to the Stage by Gdx.input which interfaces with the OS, which is why you have to register the stage as an InputProcessor.


Thanks for your contributions:

  • Mario Zechner
  • Wesker
  • Eric S.
  • mcortez
Comment by, Dec 8, 2012

This is not up to date. The links are down! Thanks to refresh this soon...

Comment by, May 13, 2013

All links are dead...

Comment by, May 16, 2013

Fix the links please....

Comment by, Mar 1, 2014

all links are dead please up to date them

Sign in to add a comment
Powered by Google Project Hosting