CPAnimationSprite
A scene objet tailor-made for showing animations based on CPAnimation.
This sprite allows to implement a visual scene object that has one or more animations associated with it. These
animations can be controlled either by the sprite itself or from the outside. This class provides necessary
implementation for update and render methods. Make sure to call super
if overriding any of
these methods.
There are additional methods that allow access to and the control of the animation in the sprite:
Typically, to create a moving sprite, one would override this class and implement movement logic
in overridden update method (making sure to call super
), as well as
overriding getX, getY and getDim methods to return current coordinates and dimension.
Note that in most cases, one do need to override or change render method.
Attributes
- anis
Sequence of animation. Must have at least one animation in it.
- collidable
Whether or not this sprite is collidable.
- id
Optional ID of the sprite.
- initAniId
ID of the initial animation to play. This animation starts to play immediately.
- shaders
Optional sequence of shaders for this sprite. Default value is an empty list.
- tags
Optional set of organizational or grouping tags. By default, the empty set is used.
- x
Initial X-coordinate.
- y
Initial Y-coordinate.
- z
Initial Z-index.
- See also:
- Example:
See CPAnimationExample source code for an example of animation functionality.
- Source:
- CPAnimationSprite.scala
- Graph
- Supertypes
Members list
Value members
Concrete methods
Changes the currently playing animation.
Changes the currently playing animation.
Attributes
- finish
Whether or not to finish the current animation before changing to the given one. If
false
current animation will stop immediately and the next frame will play the new animation. The default value istrue
.- id
ID of the new animation to change to. Note that this animation should have been passed into the constructor of this sprite.
- reset
Whether or not to reset() the animation before it is played. Default value is
true
.- Source:
- CPAnimationSprite.scala
Checks whether this sprite contains given animation.
Checks whether this sprite contains given animation.
Attributes
- id
ID of the animation to check.
- Source:
- CPAnimationSprite.scala
Gets sequence of animation for this sprite.
Gets optional collision shape or hit box for this sprite.
Gets optional collision shape or hit box for this sprite.
Attributes
- Definition Classes
- Source:
- CPAnimationSprite.scala
Gets currently running animation. Note that animation sprite always has a running animation.
Gets currently running animation. Note that animation sprite always has a running animation.
Attributes
- Source:
- CPAnimationSprite.scala
Gets current dimension (width and height) of this object.
Gets current dimension (width and height) of this object.
Attributes
- Definition Classes
- Source:
- CPAnimationSprite.scala
Gets the optional list of shaders attached to this scene object. By default, returns an empty list. Note that shaders are called regardless of whether the object visible, in camera frame or invisible.
Gets the optional list of shaders attached to this scene object. By default, returns an empty list. Note that shaders are called regardless of whether the object visible, in camera frame or invisible.
Attributes
- Definition Classes
- Source:
- CPAnimationSprite.scala
Gets current X-coordinate of this object within dimensions of its scene. Note that returned value is allowed to be outside scene's dimension (e.g. negative value). In such cases, the clipping of the scene rendering will result in showing only portion or none of the object.
Gets current X-coordinate of this object within dimensions of its scene. Note that returned value is allowed to be outside scene's dimension (e.g. negative value). In such cases, the clipping of the scene rendering will result in showing only portion or none of the object.
Attributes
- Definition Classes
- Source:
- CPAnimationSprite.scala
Gets current Y-coordinate of this object within dimensions of its scene. Note that returned value is allowed to be outside scene's dimension (e.g. negative value). In such cases, the clipping of the scene rendering will result in showing only portion or none of the object.
Gets current Y-coordinate of this object within dimensions of its scene. Note that returned value is allowed to be outside scene's dimension (e.g. negative value). In such cases, the clipping of the scene rendering will result in showing only portion or none of the object.
Attributes
- Definition Classes
- Source:
- CPAnimationSprite.scala
Gets Z-index or order to use in rendering of this object. A pixel with higher Z-index visually overrides the overlapping pixel in the same XY-coordinate with equal or smaller Z-index.
Gets Z-index or order to use in rendering of this object. A pixel with higher Z-index visually overrides the overlapping pixel in the same XY-coordinate with equal or smaller Z-index.
Attributes
- Definition Classes
- Source:
- CPAnimationSprite.scala
Called to render this scene object. Only visible and in camera frame objects will receive this callback. This callback is called on scene object after all scene objects received update callback. Note that unlike update callbacks and shaders that are called for all scene objects on each frame, this callback is only called for scene objects that are visible and, at least partially, in camera frame.
Called to render this scene object. Only visible and in camera frame objects will receive this callback. This callback is called on scene object after all scene objects received update callback. Note that unlike update callbacks and shaders that are called for all scene objects on each frame, this callback is only called for scene objects that are visible and, at least partially, in camera frame.
Attributes
- Definition Classes
- Source:
- CPAnimationSprite.scala
Resets current animation by calling its CPAnimation.reset method.
Resets current animation by calling its CPAnimation.reset method.
Attributes
- Source:
- CPAnimationSprite.scala
Resets this sprite to its initial XYZ-coordinates.
Rewinds this sprite by changing to initial animation.
Rewinds this sprite by changing to initial animation.
Attributes
- finish
Whether or not to finish the current animation before changing to the initial one. If
false
current animation will stop immediately and the next frame will play the initial animation. The default value istrue
.- reset
Whether or not to reset the initial animation. Default value is
true
.- Source:
- CPAnimationSprite.scala
Sets or removes the callback on key frame change.
Sets or removes the callback on key frame change.
Attributes
- f
Key frame change callback function that takes CPAnimation and CPSceneObjectContext as its parameters. Use
None
to remove previously set callback.- id
ID of animation.
- Source:
- CPAnimationSprite.scala
Sets current X-coordinate. This coordinate will be returned from getX method.
Sets current X-coordinate. This coordinate will be returned from getX method.
Attributes
- d
X-coordinate to set.
- Source:
- CPAnimationSprite.scala
Sets both current XY-coordinates.
Sets both current XY-coordinates.
Attributes
- a
X-coordinate to set.
- b
Y-coordinate to set.
- Source:
- CPAnimationSprite.scala
Sets current Y-coordinate. This coordinate will be returned from getY method.
Sets current Y-coordinate. This coordinate will be returned from getY method.
Attributes
- d
Y-coordinate to set.
- Source:
- CPAnimationSprite.scala
Sets current Z-index. This index will be returned from getZ method.
Sets current Z-index. This index will be returned from getZ method.
Attributes
- d
Z-index to set.
- Source:
- CPAnimationSprite.scala
Splices in given animation. Current animation will be stopped, put on hold and the spliced in animation will play. After it is finished the algorithm will revert back to the stored animation.
Splices in given animation. Current animation will be stopped, put on hold and the spliced in animation will play. After it is finished the algorithm will revert back to the stored animation.
Attributes
- finish
Whether or not to finish the current animation before the spliced in one starts. If
false
current animation will stop immediately and the next frame will play the spliced in animation. The default value istrue
.- id
ID of the animation to splice in. Note that this animation should have been passed into the constructor of this sprite.
- reset
Whether or not to reset() spliced in animation before it is played. Default value is
true
.- Source:
- CPAnimationSprite.scala
Called to update the internal state of this scene object. This callback is called each frame on every object in the scene and it is called before any render callback. Note that all scene object will receive this callback before first render callback.
Called to update the internal state of this scene object. This callback is called each frame on every object in the scene and it is called before any render callback. Note that all scene object will receive this callback before first render callback.
Attributes
- Definition Classes
- Source:
- CPAnimationSprite.scala
Inherited methods
Compares the receiver object (this
) with the argument object (that
) for equivalence.
Compares the receiver object (this
) with the argument object (that
) for equivalence.
Any implementation of this method should be an equivalence relation:
- It is reflexive: for any instance
x
of typeAny
,x.equals(x)
should returntrue
. - It is symmetric: for any instances
x
andy
of typeAny
,x.equals(y)
should returntrue
if and only ify.equals(x)
returnstrue
. - It is transitive: for any instances
x
,y
, andz
of typeAny
ifx.equals(y)
returnstrue
andy.equals(z)
returnstrue
, thenx.equals(z)
should returntrue
.
If you override this method, you should verify that your implementation remains an equivalence relation.
Additionally, when overriding this method it is usually necessary to override hashCode
to ensure that
objects which are "equal" (o1.equals(o2)
returns true
) hash to the same scala.Int.
(o1.hashCode.equals(o2.hashCode)
).
Attributes
- that
the object to compare against this object for equality.
- Returns:
true
if the receiver object is equivalent to the argument;false
otherwise.- Definition Classes
- CPGameObject -> Any
- Inherited from:
- CPGameObject
- Source:
- CPGameObject.scala
Gets current height of this object.
Gets current height of this object.
Attributes
- See also:
- Inherited from:
- CPSceneObject
- Source:
- CPSceneObject.scala
Gets unique ID of this game object.
Gets rectangular shape of this sprite. It is basically a combination of its top-left corner XY-coordinate and sprite's dimension.
Gets rectangular shape of this sprite. It is basically a combination of its top-left corner XY-coordinate and sprite's dimension.
Attributes
- See also:
- Inherited from:
- CPSceneObject
- Source:
- CPSceneObject.scala
Gets current lifecycle state.
Gets optional set of organizational tags. Note that by default the set of tags is empty.
Gets optional set of organizational tags. Note that by default the set of tags is empty.
Attributes
- See also:
- Inherited from:
- CPGameObject
- Source:
- CPGameObject.scala
Gets current width of this object.
Gets current width of this object.
Attributes
- See also:
- Inherited from:
- CPSceneObject
- Source:
- CPSceneObject.scala
Shortcut method for hiding this object. Note that by default all scene objects are visible.
Shortcut method for hiding this object. Note that by default all scene objects are visible.
Attributes
- See also:
- Inherited from:
- CPSceneObject
- Source:
- CPSceneObject.scala
Checks the visibility flag.
Checks the visibility flag.
If object is invisible than only update method will be called on each frame. If object is visible and in camera frame - method render will be called as well to render itself. Note that shaders are called regardless of whether the object visible, in camera frame or invisible.
Attributes
- See also:
- Inherited from:
- CPSceneObject
- Source:
- CPSceneObject.scala
Callback on lifecycle object activation. Default implementation is no-op.
Callback on lifecycle object activation. Default implementation is no-op.
Attributes
- See also:
CPLifecycle.State.LF_ACTIVE
- Inherited from:
- CPLifecycle
- Source:
- CPLifecycle.scala
Callback on lifecycle object deactivation. Default implementation is no-op.
Callback on lifecycle object deactivation. Default implementation is no-op.
Attributes
- See also:
CPLifecycle.State.LF_INACTIVE
- Inherited from:
- CPLifecycle
- Source:
- CPLifecycle.scala
Callback on lifecycle object start. Default implementation is no-op.
Callback on lifecycle object start. Default implementation is no-op.
Attributes
- See also:
CPLifecycle.State.LF_STARTED
- Inherited from:
- CPLifecycle
- Source:
- CPLifecycle.scala
Callback on lifecycle object stop. Default implementation is no-op.
Callback on lifecycle object stop. Default implementation is no-op.
Attributes
- See also:
CPLifecycle.State.LF_STOPPED
- Inherited from:
- CPLifecycle
- Source:
- CPLifecycle.scala
Sets visibility flag. Note that by default all scene objects are visible.
Sets visibility flag. Note that by default all scene objects are visible.
Attributes
- vis
true
to make this object visible,false
otherwise.- See also:
- Inherited from:
- CPSceneObject
- Source:
- CPSceneObject.scala
Shortcut method for showing this object. Note that by default all scene objects are visible.
Shortcut method for showing this object. Note that by default all scene objects are visible.
Attributes
- See also:
- Inherited from:
- CPSceneObject
- Source:
- CPSceneObject.scala
Concrete fields
Initial X-coordinate of the sprite.
Initial Y-coordinate of the sprite.
Initial Z-index of the sprite.