![]() |
Cornell Cocos
Cornell Extensions to Cocos2d
|
#include <CUAnimationNode.h>
Public Member Functions | |
int | getSize () |
unsigned int | getFrame () |
void | setFrame (int frame) |
~AnimationNode () | |
bool | initWithFilmstrip (Texture2D *texture, int rows, int cols, int size) |
![]() | |
virtual std::string | getDescription () const override |
virtual void | draw (Renderer *renderer, const Mat4 &transform, uint32_t flags) override |
virtual | ~PolygonNode (void) |
![]() | |
virtual void | setTexture (const std::string &filename) |
virtual void | setTexture (Texture2D *texture) override |
virtual Texture2D * | getTexture () const override |
virtual void | setPolygon (float *vertices, int size, int offset=0) |
virtual void | setPolygon (const Poly2 &poly) |
virtual void | setPolygon (const Rect &rect) |
const Poly2 & | getPolygon () const |
virtual void | shiftPolygon (float dx, float dy) |
const Rect & | getBoundingRect () const |
void | setBlendFunc (const BlendFunc &blendFunc) override |
const BlendFunc & | getBlendFunc () const override |
virtual void | setOpacityModifyRGB (bool modify) override |
virtual bool | isOpacityModifyRGB (void) const override |
void | flipHorizontal (bool flag) |
bool | isFlipHorizontal () const |
void | flipVertical (bool flag) |
bool | isFlipVertical () const |
virtual | ~TexturedNode (void) |
virtual bool | init () override |
virtual bool | init (float *vertices, int size, int offset=0) |
virtual bool | init (const Poly2 &poly) |
virtual bool | init (const Rect &rect) |
virtual bool | initWithFile (const std::string &filename) |
virtual bool | initWithFile (const std::string &filename, float *vertices, int size, int offset=0) |
virtual bool | initWithFile (const std::string &filename, const Poly2 &poly) |
virtual bool | initWithFile (const std::string &filename, const Rect &rect) |
virtual bool | initWithTexture (Texture2D *texture) |
virtual bool | initWithTexture (Texture2D *texture, float *vertices, int size, int offset=0) |
virtual bool | initWithTexture (Texture2D *texture, const Poly2 &poly) |
virtual bool | initWithTexture (Texture2D *texture, const Rect &rect) |
Static Public Member Functions | |
static AnimationNode * | create (Texture2D *texture, int rows, int cols) |
static AnimationNode * | create (Texture2D *texture, int rows, int cols, int size) |
![]() | |
static PolygonNode * | create () |
static PolygonNode * | create (float *vertices, int size, int offset=0) |
static PolygonNode * | create (const Poly2 &poly) |
static PolygonNode * | create (const Rect &rect) |
static PolygonNode * | createWithFile (const std::string &filename) |
static PolygonNode * | createWithFile (const std::string &filename, float *vertices, int size, int offset=0) |
static PolygonNode * | createWithFile (const std::string &filename, const Poly2 &poly) |
static PolygonNode * | createWithFile (const std::string &filename, const Rect &rect) |
static PolygonNode * | createWithTexture (Texture2D *texture) |
static PolygonNode * | createWithTexture (Texture2D *texture, float *vertices, int size, int offset=0) |
static PolygonNode * | createWithTexture (Texture2D *texture, const Poly2 &poly) |
static PolygonNode * | createWithTexture (Texture2D *texture, const Rect &rect) |
Public Attributes | |
CC_CONSTRUCTOR_ACCESS | __pad0__: AnimationNode() |
![]() | |
CC_CONSTRUCTOR_ACCESS | __pad0__: PolygonNode(void) |
![]() | |
CC_CONSTRUCTOR_ACCESS | __pad0__: TexturedNode(void) |
Additional Inherited Members | |
![]() | |
virtual void | generateRenderData () override |
![]() | |
TrianglesCommand::Triangles & | allocTriangles (const Poly2 &poly) |
void | clearRenderData () |
void | updateColor () override |
void | updateBlendFunc () |
void | updateTextureCoords () |
![]() | |
Texture2D * | _texture |
Poly2 | _polygon |
BlendFunc | _blendFunc |
bool | _insideBounds |
bool | _opacityModifyRGB |
TrianglesCommand | _command |
TrianglesCommand::Triangles | _triangles |
bool | _flipHorizontal |
bool | _flipVertical |
Class to support simple film strip animation
A filmstrip is just a sprite sheet. The creation API is very similar to the class Sprite. However, you must also specify the rows and columns in the sprite sheet so that it can break up the images for you.
The constructors always set this object equal to a rectangle the same size as a single frame in the sprite sheet. However, this class extends PolygonNode and not Sprite. Therefore you could conceivably animate the filmstrip over polygons. This can have undesirable effects if the polygon coordinate extend beyond a single animation frame; the Cocos2d renderer does not allow us to wrap a single frame of a texture atlas.
For example, suppose you have a filmstrip where each frame has a given width and height. Then setting the polygon to a triangle with vertices (0,0), (width/2, height), and (width,height) is okay. However, the vertices (0,0), (width, 2*height), and (2*width, height) is not.
|
inline |
Disposes of a filmstrip and its contents
|
static |
Creates a new filmstrip node from the given texture.
The size of the node is equal to the size of a single frame in the filmstrip. To resize the node, scale it up or down. Do NOT change the polygon, as that will interfere with the animation.
texture | The texture image to use |
rows | The number of rows in the filmstrip |
cols | The number of columns in the filmstrip |
a reference to this texture
|
static |
Creates a new filmstrip from the given texture.
The parameter size is to indicate that there are unused frames in the filmstrip. The value size must be less than or equal to rows*cols, or this constructor will raise an error.
The size of the node is equal to the size of a single frame in the filmstrip. To resize the node, scale it up or down. Do NOT change the polygon, as that will interfere with the animation.
texture | The texture image to use |
rows | The number of rows in the filmstrip |
cols | The number of columns in the filmstrip |
size | The number of frames in the filmstrip |
a reference to this texture
|
inline |
Returns the current active frame.
|
inline |
Returns the number of frames in this filmstrip.
bool AnimationNode::initWithFilmstrip | ( | Texture2D * | texture, |
int | rows, | ||
int | cols, | ||
int | size | ||
) |
Initializes the film strip with the given texture.
The parameter size is to indicate that there are unused frames in the filmstrip. The value size must be less than or equal to rows*cols, or this constructor will raise an error.
The size of the node is equal to the size of a single frame in the filmstrip. To resize the node, scale it up or down. Do NOT change the polygon, as that will interfere with the animation.
texture | The texture image to use |
rows | The number of rows in the filmstrip |
cols | The number of columns in the filmstrip |
size | The number of frames in the filmstrip |
a reference to this texture
void AnimationNode::setFrame | ( | int | frame | ) |
Sets the active frame as the given index.
If the frame index is invalid, an error is raised.
frame | the index to make the active frame |