aboutsummaryrefslogtreecommitdiff
path: root/src/libjin/graphics/je_sprite.h
blob: fe38a4a2a3a3a414c304b9ff2aaa6cbd72c88fc9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#ifndef __JE_SPRITE_H__
#define __JE_SPRITE_H__

#include "../common/je_types.h"
#include "../math/je_vector2.hpp"

#include "je_color.h"
#include "je_graphic.h"
#include "je_renderable.h"

namespace JinEngine
{
    namespace Graphics
    {

        /// 
        /// A sprite is unit of rendering. Animation is based on sprite, but not texture or other graphic stuff.
        /// 
        class Sprite : public Object, public Renderable
        {
        public:

            Sprite(const Graphic* graphic, const Math::Quad& quad, Origin origin);

            Sprite(const Graphic* graphic, const Math::Quad& quad, float ox, float oy);

            Sprite(const Graphic* graphic, Origin origin);

            Sprite(const Graphic* graphic, float ox, float oy);

            virtual ~Sprite();

            Math::Vector2<int> getSize();

            void render(float x, float y, float sx, float sy, float r) const override;

        private:

            void setOrigin(Origin origin);

            const Math::Vector2<float> mOrigin;

            ///
            /// Quad of graphic.
            ///
            const Math::Quad mQuad;

            const Graphic* mGraphic;

        };

    } // namespace Graphics
} // namespace JinEngine

#endif