com.annahid.libs.artenus.entities
EntityPair
Represents a pair of connected entities. This class is preferred to
EntityCollection
whenever you want to encapsulate only two entities. public class EntityPair implements Entity, Animatable, Touchable, Transformable, Renderable
Field Summary
| Modifier and Type | Field and Description |
|---|---|
protected | animHolds the animation handler affecting the entities in the pair. |
Constructor Summary
| Modifier and Type | Constructor and Description |
|---|---|
public | EntityPair(Entity first, Entity second) Constructs a new entity pair, with given entities. |
Method Summary
| Modifier and Type | Method and Description |
|---|---|
public void | advance(float elapsedTime) Advances the animation for this animatable. |
public float | getAlpha() Gets the transparency value for this renderable. |
public AnimationHandler | getAnimation() Gets the animation handler currently affecting this animatable. |
public RGB | getColorFilter() Gets the color filter for this entity. |
public final Entity | getFirst() Gets the first entity in this pair. |
public Point2D | getPosition() Gets the current position of this entity. |
public float | getRotation() Gets the current rotational angle of this entity. |
public Point2D | getScale() Gets the 2-dimensional scaling factor for this entity. |
public final Entity | getSecond() Gets the second entity in this pair. |
public boolean | handleTouch(TouchEvent event) Called whenever a touch event arrives. |
public boolean | hasBehavior(Behaviors behavior) Determines whether this entity pair has the specified behavior. |
public void | move(float amountX, float amountY) Moves this entity the given distance. |
public void | onAttach(Scene scene) Called when this entity is associated with a scene. |
public void | onDetach(Scene scene) Called when this entity is dissociated with a scene. |
public void | render(RenderingContext ctx, int flags) Renders both entities in the pair. |
public void | rotate(float angle) Rotates this entity the given number of degrees. |
public void | setAlpha(float alpha) Sets the transparency value for this renderable. |
public void | setAnimation(AnimationHandler animation) Assigns an animation handler to handle animations for this animatable. |
public void | setColorFilter(float r, float g, float b) Sets the color filter for this entity. |
public void | setColorFilter(RGB rgb) Sets the color filter for this entity. |
public void | setPosition(Point2D position) Sets the position of this entity. |
public void | setPosition(float x, float y) Sets the position of this entity. |
public void | setRotation(float angle) Sets the rotational angle of this entity. |
public void | setScale(float scaleValue) Sets the scaling factor for this entity. |
public void | setScale(float scaleX, float scaleY) Sets the scaling factor for this entity, specifying different values horizontally and
vertically. |
Methods inherited from java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitConstructor Detail
| EntityPair | ||||
|---|---|---|---|---|
public EntityPair(
Entity first,
Entity second
)Constructs a new entity pair, with given entities.Parameters:
|
Method Detail
| advance |
|---|
public void advance(
float elapsedTime
)Advances the animation for this animatable. This method is called once per animation frame. Specified By:
|
| getAlpha |
|---|
public float getAlpha() Gets the transparency value for this renderable. Specified By:
Returns:
The alpha value for transparency |
| getAnimation |
|---|
public AnimationHandler getAnimation() Gets the animation handler currently affecting this animatable. Specified By:
Returns:
Animation handler |
| getColorFilter |
|---|
public RGB getColorFilter() Gets the color filter for this entity. Modifying the fields in the returned value affects
the color filter. Specified By:
Returns:
The color filter |
| getFirst |
|---|
public final Entity getFirst() Gets the first entity in this pair. Returns:
The first entity |
| getPosition |
|---|
public Point2D getPosition() Gets the current position of this entity. Specified By:
Returns:
Current 2-dimensional position |
| getRotation |
|---|
public float getRotation() Gets the current rotational angle of this entity. Specified By:
Returns:
Rotational angle in degrees |
| getScale |
|---|
public Point2D getScale() Gets the 2-dimensional scaling factor for this entity. Specified By:
Returns:
The scaling factor over horizontal and vertical axes |
| getSecond |
|---|
public final Entity getSecond() Gets the second entity in this pair. Returns:
The second entity |
| handleTouch |
|---|
public boolean handleTouch(
TouchEvent event
)Called whenever a touch event arrives. Specified By:
Returns:
true if handled, false otherwise |
| hasBehavior | ||
|---|---|---|
public boolean hasBehavior(
Behaviors behavior
)Determines whether this entity pair has the specified behavior. Parameters:
Specified By:
Returns:
true if this entity has the behavior, false otherwise |
| move |
|---|
public void move(
float amountX,
float amountY
)Moves this entity the given distance. The translation will be relative to this entity's
current position. Specified By:
|
| onAttach |
|---|
public void onAttach(
Scene scene
)Called when this entity is associated with a scene. Specified By:
|
| onDetach |
|---|
public void onDetach(
Scene scene
)Called when this entity is dissociated with a scene. Specified By:
|
| render | ||
|---|---|---|
public void render(
RenderingContext ctx,
int flags
)Renders both entities in the pair. Parameters:
Specified By:
render in Renderable |
| rotate |
|---|
public void rotate(
float angle
)Rotates this entity the given number of degrees. This rotation will be relative to this
entity's current rotational angle. Specified By:
|
| setAlpha |
|---|
public void setAlpha(
float alpha
)Sets the transparency value for this renderable. An alpha value of 1 indicates a fully opaque
renderable and a value of 0 is an invisible sprite. Any value in between can be specified to
achieve transparency. Specified By:
|
| setAnimation |
|---|
public void setAnimation(
AnimationHandler animation
)Assigns an animation handler to handle animations for this animatable. Specified By:
|
| setColorFilter |
|---|
public void setColorFilter(
float r,
float g,
float b
)Sets the color filter for this entity. The original colors should be multiplied by this color
when rendering. Specified By:
|
| setColorFilter |
|---|
public void setColorFilter(
RGB rgb
)Sets the color filter for this entity. The original colors should be multiplied by this color
when rendering. Specified By:
|
| setPosition |
|---|
public void setPosition(
Point2D position
)Sets the position of this entity. Specified By:
|
| setPosition |
|---|
public void setPosition(
float x,
float y
)Sets the position of this entity. Specified By:
|
| setRotation |
|---|
public void setRotation(
float angle
)Sets the rotational angle of this entity. Specified By:
|
| setScale |
|---|
public void setScale(
float scaleValue
)Sets the scaling factor for this entity. Horizontal and vertical scaling factors will be set
to the same value. Specified By:
|
| setScale |
|---|
public void setScale(
float scaleX,
float scaleY
)Sets the scaling factor for this entity, specifying different values horizontally and
vertically. Specified By:
|