class Sprite : public WorldObject
{
- public:
+public:
Sprite(std::string name, Actor actor);
- void setAnimation(int animation) { mActor.mCurrentAnimation = animation; }/**< changes to the specified animation beginning at 0. */
- SpriteFrame* getAnimation() { return &mActor.mAnimations[mActor.mCurrentAnimation]->mFrames[mActor.mFrame]; }/**< returns active animation. (actually the current frame within the animation) \todo see if this is slower maybe undo */
- void setFrame(int frame) { mActor.mFrame = frame; }/**< cahnges to the specified frame of the animation beginning at 0. */
- int getFrame() { return mActor.mFrame; }/**< returns active frame. */
- void setSpeed(float speed) { mSpeed = speed; }/**< sets the Sprite's speed. */
- float getSpeed() { return mSpeed;}/**< returns a Sprite's current speed. */
- void toggleAnim() { mAnimating = !mAnimating; }/**< Pauses or resumes an animation. */
- void startAnim() {mAnimating = 1; }/**< Causes the animation to play. */
- void stopAnim() {mAnimating = 0; }/**< Causes the animation to stop. */
- void rewind() {mActor.mFrame = 0; }/**< Resets the Sprite's animation to the first frame. */
- void draw();/**< draws Sprite. */
- void drawCollisions();/**< Draws Collision data for the Object (from outside) */
- void update();/**< Update to run each loop */
- Sprite* collisionWithSprite(string name);/**< checks for collision with sprite of a given name. */
- vector<Collision*>& getCollisionData();/**< Returns collision data */
-
-
+ /**
+ Changes to the specified animation beginning at 0.
+ \param animation The index representing the animation to move to
+ */
+ void setAnimation(int animation) { mActor.mCurrentAnimation = animation; }
+ /**
+ Returns active animation. (actually the current frame within the animation) \todo see if this is slower maybe undo
+ \return Pointer to the active Animation
+ */
+ SpriteFrame* getAnimation() { return &mActor.mAnimations[mActor.mCurrentAnimation]->mFrames[mActor.mFrame]; }
+ /**
+ Changes to the specified frame of the animation beginning at 0.
+ \param frame The frame of the animation to move to
+ */
+ void setFrame(int frame) { mActor.mFrame = frame; }
+ /**
+ Returns active frame.
+ \return The index representing the Active Frame
+ */
+ int getFrame() { return mActor.mFrame; }
+ /**
+ Sets the Sprite's speed.
+ \param speed Speed for the sprite (directly correlates to number of pixels)
+ */
+ void setSpeed(float speed) { mSpeed = speed; }
+ /**
+ Returns a Sprite's current speed.
+ \return Speed of the Sprite
+ */
+ float getSpeed() { return mSpeed;}
+ /**
+ Pauses or resumes an animation.
+ */
+ void toggleAnim() { mAnimating = !mAnimating; }
+ /**< Causes the animation to play. */
+ void startAnim() {mAnimating = 1; }
+ /**< Causes the animation to stop. */
+ void stopAnim() {mAnimating = 0; }
+ /**< Resets the Sprite's animation to the first frame. */
+ void rewind() {mActor.mFrame = 0; }
+ /**
+ Draws Sprite.
+ */
+ void draw();
+ /**
+ Draws Collision data for the Object (from outside)
+ */
+ void drawCollisions();
+ /**
+ Update to run each loop
+ */
+ void update();
+ /**
+ Checks for collision with sprite of a given name.
+ */
+ Sprite* collisionWithSprite(string name);
+ /**
+ Returns collision data
+ */
+ vector<Collision*>& getCollisionData();
+
+
private:
- bool mAnimating;/**< Tells whether to animate or not */
- bool mDrawn;/**< Tells if the object has been drawn the first time */
- float mSpeed;/**< Movement speed of the Sprite. */
- long mLastUpdate;/**< Number that indicates when the Sprite has last updated. Overflows in about 24 days so no worries. */
- Actor mActor;/**< This Sprite's Actor. */
- Behavior mBehavior;/**< Sprite's Behavior */
+ /// Tells whether to animate or not
+ bool mAnimating;
+ /// Tells if the object has been drawn the first time
+ bool mDrawn;
+ /// Movement speed of the Sprite.
+ float mSpeed;
+ /// Number that indicates when the Sprite has last updated. Overflows in about 24 days so no worries.
+ long mLastUpdate;
+ /// This Sprite's Actor.
+ Actor mActor;
+ /// Sprite's Behavior
+ Behavior mBehavior;
};
#endif