|
libgdx API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.badlogic.gdx.scenes.scene2d.Actor
public abstract class Actor
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.
The position of an Actor is coincident with its unrotated, unscaled bottom left corner.
An Actor can be a child of a Group or the Stage. The object it belongs to is called the Actor's parent. An Actor's position is always relative to the bottom left corner of its parent.
Every Actor must have a unique name within a Stage.
An Actor can receive touch events when its touchable
attribute is set to true. The Stage will delegate touch events to
an Actor in this case, calling its touchDown(float, float, int)
, touchUp(float, float, int)
and
touchDragged(float, float, int)
methods. The coordinates passed to an Actor will be in the Actor's coordinate system,
easing the pain of intersection testing. The coordinate system has it's origin at the Actor's rotated and scaled bottom left
corner, with the x-axis pointing to the right and the y-axis pointing to the left.
An Actor can be intersection tested via a call this its hit(float, float)
method. The coordinates given are again in
the Actor's coordinate system.
An Actor might render itself when its draw(SpriteBatch, float)
method is called. The projection and transform matrices
are setup so that an Actor can simply call the
SpriteBatch.draw(com.badlogic.gdx.graphics.Texture, float, float, float, float, float, float, float, float, float, int, int, int, int, boolean, boolean)
method to render himself. Using a Sprite
instance is also an option. An Actor might decide to not render itself at all
or chose another way to render itself. For the later it has to call SpriteBatch.end()
first, setup up all render states
needed to render itself, render itself and then call SpriteBatch.begin()
again so that the rendering for other Actor's
is undisturbed. You have to know what you do if you want to try this.
An Actor can be controlled by Action
s. An Action will modify some of the attributes of an Actor such as its position or
rotation. Actions can be chained and make for rather sophisticated time based behaviour.
Field Summary | |
---|---|
protected PooledLinkedList<Action> |
actions
|
Color |
color
|
float |
height
|
java.lang.String |
name
|
float |
originX
|
float |
originY
|
Group |
parent
|
float |
rotation
|
float |
scaleX
|
float |
scaleY
|
boolean |
touchable
|
boolean |
visible
|
float |
width
|
float |
x
|
float |
y
|
Constructor Summary | |
---|---|
Actor()
Creates an actor without a name. |
|
Actor(java.lang.String name)
|
Method Summary | |
---|---|
void |
act(float delta)
|
void |
action(Action action)
Adds an Action to the Actor. |
void |
clearActions()
Clears all actions of this Actor. |
abstract void |
draw(SpriteBatch batch,
float parentAlpha)
Draws the Actor. |
abstract Actor |
hit(float x,
float y)
|
boolean |
isMarkedToRemove()
States if this actor is to be removed by its parent. |
boolean |
keyDown(int keycode)
|
boolean |
keyTyped(char character)
|
boolean |
keyUp(int keycode)
|
void |
markToRemove(boolean remove)
Marks the Actor to be removed by its parent. |
void |
remove()
Removes this actor from the Stage |
boolean |
scrolled(int amount)
|
void |
toLocalCoordinates(Vector2 point)
Transforms the given point in stage coordinates to the Actor's local coordinate system. |
java.lang.String |
toString()
|
abstract boolean |
touchDown(float x,
float y,
int pointer)
|
abstract void |
touchDragged(float x,
float y,
int pointer)
|
boolean |
touchMoved(float x,
float y)
|
abstract void |
touchUp(float x,
float y,
int pointer)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public Group parent
public final java.lang.String name
public boolean touchable
public boolean visible
public float x
public float y
public float width
public float height
public float originX
public float originY
public float scaleX
public float scaleY
public float rotation
public final Color color
protected PooledLinkedList<Action> actions
Constructor Detail |
---|
public Actor()
public Actor(java.lang.String name)
Method Detail |
---|
public abstract void draw(SpriteBatch batch, float parentAlpha)
FadeIn
and
other Actions to have an effect even if they are only set on the parent of the Actor.
batch
- the spritebatch to render withparentAlpha
- the parent's alpha value.public abstract boolean touchDown(float x, float y, int pointer)
public abstract void touchUp(float x, float y, int pointer)
public abstract void touchDragged(float x, float y, int pointer)
public boolean touchMoved(float x, float y)
public boolean scrolled(int amount)
public boolean keyDown(int keycode)
public boolean keyUp(int keycode)
public boolean keyTyped(char character)
public abstract Actor hit(float x, float y)
public void toLocalCoordinates(Vector2 point)
point
- the pointpublic void remove()
public void act(float delta)
public void action(Action action)
Action
to the Actor. Actions will be automatically performed in the order added to the Actor and will be
removed when they are done.
action
- the actionpublic void clearActions()
public java.lang.String toString()
toString
in class java.lang.Object
public void markToRemove(boolean remove)
Actor
to be removed by its parent.
The actual removal happens in the Group.act(float)
method of the parent and after the parent has called
act(float)
on this Actor
.
remove
- whether the parent is supposed to remove this Actor
public boolean isMarkedToRemove()
true
when the actor is to be removed or false
otherwise
|
libgdx API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |