Artenus 2D Framework
Artenus Reference
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 TypeField and Description
protected anim
Holds the animation handler affecting the entities in the pair.

Constructor Summary

Modifier and TypeConstructor and Description
public EntityPair(Entity first, Entity second)
Constructs a new entity pair, with given entities.

Method Summary

Modifier and TypeMethod and Description
public voidadvance(float elapsedTime)
Advances the animation for this animatable.
public floatgetAlpha()
Gets the transparency value for this renderable.
public AnimationHandlergetAnimation()
Gets the animation handler currently affecting this animatable.
public RGBgetColorFilter()
Gets the color filter for this entity.
public final EntitygetFirst()
Gets the first entity in this pair.
public Point2DgetPosition()
Gets the current position of this entity.
public floatgetRotation()
Gets the current rotational angle of this entity.
public Point2DgetScale()
Gets the 2-dimensional scaling factor for this entity.
public final EntitygetSecond()
Gets the second entity in this pair.
public booleanhandleTouch(TouchEvent event)
Called whenever a touch event arrives.
public booleanhasBehavior(Behaviors behavior)
Determines whether this entity pair has the specified behavior.
public voidmove(float amountX, float amountY)
Moves this entity the given distance.
public voidonAttach(Scene scene)
Called when this entity is associated with a scene.
public voidonDetach(Scene scene)
Called when this entity is dissociated with a scene.
public voidrender(RenderingContext ctx, int flags)
Renders both entities in the pair.
public voidrotate(float angle)
Rotates this entity the given number of degrees.
public voidsetAlpha(float alpha)
Sets the transparency value for this renderable.
public voidsetAnimation(AnimationHandler animation)
Assigns an animation handler to handle animations for this animatable.
public voidsetColorFilter(float r, float g, float b)
Sets the color filter for this entity.
public voidsetColorFilter(RGB rgb)
Sets the color filter for this entity.
public voidsetPosition(Point2D position)
Sets the position of this entity.
public voidsetPosition(float x, float y)
Sets the position of this entity.
public voidsetRotation(float angle)
Sets the rotational angle of this entity.
public voidsetScale(float scaleValue)
Sets the scaling factor for this entity.
public voidsetScale(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, wait

Field Detail

anim
protected anim
Holds the animation handler affecting the entities in the pair.

Constructor Detail

EntityPair
public  EntityPair(
    Entity first,
    Entity second
)
Constructs a new entity pair, with given entities.
Parameters:
firstThe first entity in the pair
secondThe second entity in the pair

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:
behaviorBehavior to be checked
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:
flagsRendering flags
Specified By:
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: