Space Fighter
A "shmup" game for Computer Programming C++
Loading...
Searching...
No Matches
Animation.h
Go to the documentation of this file.
1
2/*
3 ██╗ ██╗ █████╗ ████████╗ █████╗ ███╗ ██╗ █████╗
4 ██║ ██╔╝ ██╔══██╗ ╚══██╔══╝ ██╔══██╗ ████╗ ██║ ██╔══██╗
5 █████╔╝ ███████║ ██║ ███████║ ██╔██╗ ██║ ███████║
6 ██╔═██╗ ██╔══██║ ██║ ██╔══██║ ██║╚██╗██║ ██╔══██║
7 ██║ ██╗ ██║ ██║ ██║ ██║ ██║ ██║ ╚████║ ██║ ██║
8 ╚═╝ ╚═╝ ╚═╝ ╚═╝/\ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝
9 /vvvvvvvvvvvvvvvvvvv \=========================================,
10 `^^^^^^^^^^^^^^^^^^^ /---------------------------------------"
11 Katana Engine \/ © 2012 - Shuriken Studios LLC
12 http://www.shurikenstudios.com
13*/
14
15#pragma once
16
17namespace KatanaEngine
18{
20 class Animation : public Resource
21 {
22
23 public:
24
25 Animation();
26 virtual ~Animation();
27
28
31 virtual void Update(const GameTime& gameTime);
32
37 virtual bool Load(const std::string &path, ResourceManager *pManager);
38
43 virtual bool IsCloneable() const { return true; }
44
47 virtual Resource *Clone();
48
51 virtual Region *GetCurrentFrame() { return m_frames[m_currentIndex]; }
52
55 virtual int GetCurrentIndex() { return m_currentIndex; }
56
59 virtual Region *GetFrame(const int index) { return m_frames[index]; }
60
63 virtual Texture *GetTexture() const { return m_pTexture; }
64
67 virtual void SetTexture(Texture *pTexture) { m_pTexture = pTexture; }
68
72 virtual void SetCurrentFrame(const unsigned int index);
73
76 virtual bool IsPlaying() const { return m_isPlaying; }
77
79 virtual void Play() { m_isPlaying = true; }
80
82 virtual void Pause() { m_isPlaying = false; }
83
85 virtual void Stop();
86
90 virtual void SetLoopCount(uint16_t loops = -1) { m_loopCounter = loops; }
91
92
93 private:
94
95 std::vector<Region *> m_frames;
96
97 Texture *m_pTexture = nullptr;
98
99 double m_secondsPerFrame = 0;
100
101 double m_currentFrameTime = 0;
102
103 int m_currentIndex = 0;
104
105 int m_loopCounter = 0;
106
107 bool m_isPlaying = false;
108
109 };
110}
Represents timing and framing values for texture animations.
Definition Animation.h:21
virtual void SetCurrentFrame(const unsigned int index)
Sets the current frame of the animation.
virtual void Pause()
Pauses the animation.
Definition Animation.h:82
virtual void SetTexture(Texture *pTexture)
Sets the texture of the animation.
Definition Animation.h:67
virtual Texture * GetTexture() const
Gets a pointer to the texture of the animation.
Definition Animation.h:63
virtual bool IsPlaying() const
Determines if the animation is playing.
Definition Animation.h:76
virtual Region * GetCurrentFrame()
Gets a pointer to the current frame.
Definition Animation.h:51
virtual void Update(const GameTime &gameTime)
Updates the animation.
Definition Animation.cpp:40
virtual int GetCurrentIndex()
Gets the index of the current frame.
Definition Animation.h:55
virtual bool IsCloneable() const
Used to determine if the animation is cloneable.
Definition Animation.h:43
virtual void SetLoopCount(uint16_t loops=-1)
Sets how many times the animation will run before it stops.
Definition Animation.h:90
virtual Resource * Clone()
Used to create a clone of the animation.
virtual bool Load(const std::string &path, ResourceManager *pManager)
Load the desired animation into memory.
Definition Animation.cpp:62
virtual void Play()
Starts or resumes the animation.
Definition Animation.h:79
virtual Region * GetFrame(const int index)
Gets a pointer to the indexed frame.
Definition Animation.h:59
virtual void Stop()
Stops the animation.
Contains timing values for game updates and rendering.
Definition GameTime.h:21
Defines a rectangular region defined by a point, height, width.
Definition Region.h:21
Base class for all resource types to be managed by the ResourceManager class.
Definition Resource.h:23
Loads and manages the lifespan of objects from external files.
Represents a 2D grid of texels.
Definition Texture.h:21
Katana Engine is a library of classes, interfaces, and value types that provides a foundation for dev...
Definition Animation.cpp:18