Arcade Shooter
Animation.h
1 
2 /* ██╗ ██╗ █████╗ ████████╗ █████╗ ███╗ ██╗ █████╗
3  ██║ ██╔╝ ██╔══██╗ ╚══██╔══╝ ██╔══██╗ ████╗ ██║ ██╔══██╗
4  █████╔╝ ███████║ ██║ ███████║ ██╔██╗ ██║ ███████║
5  ██╔═██╗ ██╔══██║ ██║ ██╔══██║ ██║╚██╗██║ ██╔══██║
6  ██║ ██╗ ██║ ██║ ██║ ██║ ██║ ██║ ╚████║ ██║ ██║
7  ╚═╝ ╚═╝ ╚═╝ ╚═╝/\ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝
8  /vvvvvvvvvvvvvvvvvvv \=========================================,
9  `^^^^^^^^^^^^^^^^^^^ /---------------------------------------"
10  Katana Engine \/ © 2012 - Shuriken Studios LLC */
11 
12 #pragma once
13 
14 namespace KatanaEngine
15 {
17  class Animation : public Resource
18  {
19 
20  public:
21 
22  Animation();
23  virtual ~Animation();
24 
25 
28  virtual void Update(const GameTime *pGameTime);
29 
34  virtual bool Load(const std::string &path, ResourceManager *pManager);
35 
40  virtual bool IsCloneable() const { return true; }
41 
44  virtual Resource *Clone();
45 
48  virtual Region *GetCurrentFrame() { return m_frames[m_currentIndex]; }
49 
52  virtual Region *GetFrame(const int index) { return m_frames[index]; }
53 
56  virtual Texture *GetTexture() const { return m_pTexture; }
57 
60  virtual void SetTexture(Texture *pTexture) { m_pTexture = pTexture; }
61 
65  virtual void SetCurrentFrame(const unsigned int index);
66 
69  virtual bool IsPlaying() const { return m_isPlaying; }
70 
72  virtual void Play() { m_isPlaying = true; }
73 
75  virtual void Pause() { m_isPlaying = false; }
76 
78  virtual void Stop();
79 
83  virtual void SetLoopCount(uint16_t loops = -1) { m_loopCounter = loops; }
84 
85 
86  private:
87 
88  std::vector<Region *> m_frames;
89 
90  Texture *m_pTexture;
91 
92  double m_secondsPerFrame;
93 
94  double m_currentFrameTime;
95 
96  int m_currentIndex;
97 
98  int m_loopCounter;
99 
100  bool m_isPlaying;
101 
102  };
103 }
virtual void Pause()
Pauses the animation.
Definition: Animation.h:75
Represents a 2D grid of texels.
Definition: Texture.h:17
virtual bool Load(const std::string &path, ResourceManager *pManager)
Load the desired animation into memory.
Definition: Animation.cpp:59
virtual Texture * GetTexture() const
Gets a pointer to the texture of the animation.
Definition: Animation.h:56
virtual bool IsCloneable() const
Used to determine if the animation is cloneable.
Definition: Animation.h:40
Contains timing values for game updates and rendering.
Definition: GameTime.h:17
virtual void Update(const GameTime *pGameTime)
Updates the animation.
Definition: Animation.cpp:37
virtual void Play()
Starts or resumes the animation.
Definition: Animation.h:72
virtual Resource * Clone()
Used to create a clone of the animation.
Definition: Animation.cpp:120
virtual void SetCurrentFrame(const unsigned int index)
Sets the current frame of the animation.
Definition: Animation.cpp:104
virtual void SetTexture(Texture *pTexture)
Sets the texture of the animation.
Definition: Animation.h:60
Base class for all resource types to be managed by the ResourceManager class.
Definition: Resource.h:19
virtual void Stop()
Stops the animation.
Definition: Animation.cpp:114
virtual void SetLoopCount(uint16_t loops=-1)
Sets how many times the animation will run before it stops.
Definition: Animation.h:83
Represents timing and framing values for texture animations.
Definition: Animation.h:17
virtual Region * GetCurrentFrame()
Gets a pointer to the current frame.
Definition: Animation.h:48
virtual bool IsPlaying() const
Determines if the animation is playing.
Definition: Animation.h:69
Defines a rectangular region defined by a point, height, width.
Definition: Region.h:17
Loads and manages the lifespan of objects from external files.
Definition: ResourceManager.h:17
virtual Region * GetFrame(const int index)
Gets a pointer to the indexed frame.
Definition: Animation.h:52
Katana Engine is a library of classes, interfaces, and value types that provides a foundation for dev...
Definition: Animation.cpp:14