![]() The stage’s viewport is determined by a Viewport instance. Calling act on the stage is optional, but actor actions and enter/exit events will not occur if it is omitted. By default, the Actor act method updates all actions on the actor. This causes the act method on every actor in the scene to be called, allowing the actors to take some action based on time. Stage has an act method that takes a delta time since last frame. If an actor in the stage handles an event, stage’s InputProcessor methods will return true, indicating the event has been handled and should not continue on to the next InputProcessor. If the stage is being used as a UI on top of other content (eg, a HUD), an InputMultiplexer can be used to first give the stage a chance to handle an event. When it receives input events, it fires them on the appropriate actors. The Stage class has a camera, SpriteBatch, and a root group and handles drawing the actors and distributing input events. The Group class is an actor that may have child actors. The Actor class is a node in the graph which has a position, rectangular size, origin, scale, rotation, and color. When used solely for UIs or for apps that don’t care about MVC, the coupling is not an issue. This coupling makes MVC separation difficult. Actors are also the view, as they know how to draw themselves. Actors store data that is often considered model data in games, such as their size and position. Scene graphs have the drawback that they couple model and view. ![]() The scene2d.ui package provides many actors and other utilities specifically for building UIs. ![]() Scene2d is well equipped for laying out, drawing, and handling input for game menus, HUD overlays, tools, and other UIs. Actions can be chained and combined for complex effects. The event system is flexible, enabling parent actors to handle events before or after children.Īction system for easy manipulation of actors over time. Routing of input and other events to the appropriate actor. Each actor determines if it is hit using its own un-rotated and unscaled coordinate system. Hit detection of rotated and scaled actors. Each actor draws in its own un-rotated and unscaled coordinate system where 0,0 is the bottom left corner of the actor. Child actors always work in their own coordinate system, parent transformations are applied transparently. Rotation and scale of a group is applied to all child actors. If you’re looking for the UI component of scene2d, see Scene2d.uiĬheck out for Scene2d examples (Image, Label etc…) Scene2d is a 2D scene graph for building applications and UIs using a hierarchy of actors.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |