projects
/
supertux.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Mirror actions now cache the horizontal flipped Surfaces, rather than flipping them...
[supertux.git]
/
lib
/
special
/
sprite.h
diff --git
a/lib/special/sprite.h
b/lib/special/sprite.h
index
05db0c6
..
8239f49
100644
(file)
--- a/
lib/special/sprite.h
+++ b/
lib/special/sprite.h
@@
-39,20
+39,25
@@
namespace SuperTux
{
std::string name;
{
std::string name;
- int x_hotspot;
- int y_hotspot;
+ /** Position correction */
+ int x_offset;
+ int y_offset;
+ /** Drawing priority in queue */
+ int z_order;
/** Frames per second */
float fps;
/** Frames per second */
float fps;
- int animation_loops;
+ /** Mirror is used to avoid duplicating left and right side
+ sprites */
+// bool mirror;
std::vector<Surface*> surfaces;
};
public:
std::vector<Surface*> surfaces;
};
public:
- /** cur has to be a pointer to data in the form of ((x-
hotspo
t 5)
- (y-
hotspo
t 10) ...) */
+ /** cur has to be a pointer to data in the form of ((x-
offse
t 5)
+ (y-
offse
t 10) ...) */
Sprite(lisp_object_t* cur);
~Sprite();
Sprite(lisp_object_t* cur);
~Sprite();
@@
-60,24
+65,46
@@
namespace SuperTux
void draw(DrawingContext& context, const Vector& pos, int layer,
Uint32 drawing_effect = NONE_EFFECT);
void draw(DrawingContext& context, const Vector& pos, int layer,
Uint32 drawing_effect = NONE_EFFECT);
+ void draw_part(DrawingContext& context, const Vector& source,
+ const Vector& size, const Vector& pos, int layer,
+ Uint32 drawing_effect = NONE_EFFECT);
+
/** Set action (or state) */
void set_action(std::string act);
/** Set action (or state) */
void set_action(std::string act);
- /* Handling animations */
+ /* Start an animation
+ -1 - for infinite
+ 0 - stopped
+ 1,2,3 - one, two, three times... */
void start_animation(int loops);
void start_animation(int loops);
+ /* Stop animation */
+ void stop_animation()
+ { start_animation(0); }
+ /** Check if animation is stopped or not */
bool check_animation();
bool check_animation();
+ /** Reverse the animation */
+ void reverse_animation(bool reverse);
float get_fps()
{ return action->fps; }
float get_fps()
{ return action->fps; }
+ /** Get current action total frames */
int get_frames()
{ return action->surfaces.size(); }
int get_frames()
{ return action->surfaces.size(); }
+ /** Get sprite's name */
std::string get_name() const
{ return name; }
std::string get_name() const
{ return name; }
+ /** Get current action name */
+ std::string get_action_name() const
+ { return action->name; }
int get_width();
int get_height();
int get_width();
int get_height();
- int get_current_frame()
+ /** Get current frame */
+ int get_frame()
{ return (int)frame; }
{ return (int)frame; }
+ /** Set current frame */
+ void set_frame(int frame_)
+ { if(frame_ > get_frames()) frame = 0; else frame = frame_; }
Surface* get_frame(unsigned int frame)
{
if(frame < action->surfaces.size())
Surface* get_frame(unsigned int frame)
{
if(frame < action->surfaces.size())
@@
-89,18
+116,24
@@
namespace SuperTux
void init_defaults(Action* act);
void parse_action(LispReader& lispreader);
void init_defaults(Action* act);
void parse_action(LispReader& lispreader);
+ /** Get an action */
+ Action* get_action(std::string act);
+
void update();
void reset();
std::string name;
float frame;
void update();
void reset();
std::string name;
float frame;
+ int animation_loops;
+ bool animation_reversed;
float last_tick;
typedef std::map <std::string, Action*> Actions;
Actions actions;
Action* action;
float last_tick;
typedef std::map <std::string, Action*> Actions;
Actions actions;
Action* action;
+ std::string next_action;
};
} //namespace SuperTux
};
} //namespace SuperTux