nomlib
Loading...
Searching...
No Matches
SpriteBatch.hpp
1/******************************************************************************
2
3 nomlib - C++11 cross-platform game engine
4
5Copyright (c) 2013, 2014 Jeffrey Carpenter <i8degrees@gmail.com>
6All rights reserved.
7
8Redistribution and use in source and binary forms, with or without
9modification, are permitted provided that the following conditions are met:
10
111. Redistributions of source code must retain the above copyright notice, this
12 list of conditions and the following disclaimer.
132. Redistributions in binary form must reproduce the above copyright notice,
14 this list of conditions and the following disclaimer in the documentation
15 and/or other materials provided with the distribution.
16
17THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
21ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28******************************************************************************/
29#ifndef NOMLIB_GRAPHICS_SPRITE_BATCH_HPP
30#define NOMLIB_GRAPHICS_SPRITE_BATCH_HPP
31
32#include "export.hpp"
33#include "nomlib/config.hpp"
34#include "nomlib/math/Rect.hpp"
35#include "nomlib/graphics/sprite/Sprite.hpp"
36#include "nomlib/graphics/sprite/SpriteSheet.hpp"
37
38namespace nom {
39
40// TODO: Consider compositing from nom::Sprite instead of inheriting!
41
43class NOM_EXPORT SpriteBatch: public Sprite
44{
45 public:
46 typedef SpriteBatch self_type;
47 typedef Sprite derived_class;
48
54
56 virtual ~SpriteBatch();
57
67 virtual void set_sprite_sheet(const SpriteSheet& sheet);
68
72 ObjectTypeInfo type() const override;
73
76
78 virtual int32 frame() const;
79
81 int32 frames() const;
82
94 void set_frame(int32 id);
95
102 virtual void draw(IDrawable::RenderTarget& target) const override;
103
110 virtual void draw(RenderTarget& target, real64 angle) const override;
111
112 protected:
114 IntRect offsets;
115
118
121
122 private:
128 virtual void update() override;
129};
130
131} // namespace nom
132
133#endif // include guard defined
const RenderWindow RenderTarget
Definition IDrawable.hpp:60
Run-time type information (RTTI) container class.
virtual void draw(IDrawable::RenderTarget &target) const override
Render the sprite frame.
virtual void update() override
Update the sprite for rendering with regard to positioning coordinates and target frame ID.
virtual ~SpriteBatch()
Destructor.
void set_frame(int32 id)
Set a new frame ID to render.
virtual void set_sprite_sheet(const SpriteSheet &sheet)
Use the sprite frames from an existing SpriteSheet object.
int32 frames() const
Obtain the number of frames available.
virtual int32 frame() const
Get the object's current sheet_id.
SpriteBatch * clone() const
Implements the required IDrawable::clone method.
int32 sheet_id_
The sheet's frame ID presently in use.
IntRect offsets
Source (input) coordinates – used for sprite sheet positioning.
virtual void draw(RenderTarget &target, real64 angle) const override
Render the sprite frame at an angle.
SpriteSheet sprite_sheet
Our attached sprite sheet object.
ObjectTypeInfo type() const override
Re-implements the IObject::type method.
Container class for deserialized sprite sheet data.