nomlib
Toggle main menu visibility
Loading...
Searching...
No Matches
include
nomlib
graphics
sprite
SpriteBatch.hpp
1
/******************************************************************************
2
3
nomlib - C++11 cross-platform game engine
4
5
Copyright (c) 2013, 2014 Jeffrey Carpenter <i8degrees@gmail.com>
6
All rights reserved.
7
8
Redistribution and use in source and binary forms, with or without
9
modification, are permitted provided that the following conditions are met:
10
11
1. Redistributions of source code must retain the above copyright notice, this
12
list of conditions and the following disclaimer.
13
2. 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
17
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
21
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24
ON 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
26
SOFTWARE, 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
38
namespace
nom {
39
40
// TODO: Consider compositing from nom::Sprite instead of inheriting!
41
43
class
NOM_EXPORT
SpriteBatch
:
public
Sprite
44
{
45
public
:
46
typedef
SpriteBatch
self_type;
47
typedef
Sprite derived_class;
48
53
SpriteBatch
();
54
56
virtual
~SpriteBatch
();
57
67
virtual
void
set_sprite_sheet
(
const
SpriteSheet
& sheet);
68
72
ObjectTypeInfo
type
()
const override
;
73
75
SpriteBatch
*
clone
()
const
;
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
117
SpriteSheet
sprite_sheet
;
118
120
int32
sheet_id_
;
121
122
private
:
128
virtual
void
update
()
override
;
129
};
130
131
}
// namespace nom
132
133
#endif
// include guard defined
nom::IDrawable::RenderTarget
const RenderWindow RenderTarget
Definition
IDrawable.hpp:60
nom::ObjectTypeInfo
Run-time type information (RTTI) container class.
Definition
ObjectTypeInfo.hpp:42
nom::SpriteBatch::draw
virtual void draw(IDrawable::RenderTarget &target) const override
Render the sprite frame.
nom::SpriteBatch::update
virtual void update() override
Update the sprite for rendering with regard to positioning coordinates and target frame ID.
nom::SpriteBatch::~SpriteBatch
virtual ~SpriteBatch()
Destructor.
nom::SpriteBatch::set_frame
void set_frame(int32 id)
Set a new frame ID to render.
nom::SpriteBatch::set_sprite_sheet
virtual void set_sprite_sheet(const SpriteSheet &sheet)
Use the sprite frames from an existing SpriteSheet object.
nom::SpriteBatch::frames
int32 frames() const
Obtain the number of frames available.
nom::SpriteBatch::frame
virtual int32 frame() const
Get the object's current sheet_id.
nom::SpriteBatch::clone
SpriteBatch * clone() const
Implements the required IDrawable::clone method.
nom::SpriteBatch::sheet_id_
int32 sheet_id_
The sheet's frame ID presently in use.
Definition
SpriteBatch.hpp:120
nom::SpriteBatch::offsets
IntRect offsets
Source (input) coordinates – used for sprite sheet positioning.
Definition
SpriteBatch.hpp:114
nom::SpriteBatch::draw
virtual void draw(RenderTarget &target, real64 angle) const override
Render the sprite frame at an angle.
nom::SpriteBatch::SpriteBatch
SpriteBatch()
nom::SpriteBatch::sprite_sheet
SpriteSheet sprite_sheet
Our attached sprite sheet object.
Definition
SpriteBatch.hpp:117
nom::SpriteBatch::type
ObjectTypeInfo type() const override
Re-implements the IObject::type method.
nom::SpriteSheet
Container class for deserialized sprite sheet data.
Definition
SpriteSheet.hpp:51
Generated on
for nomlib by
1.18.0