[Super-tux-commit] supertux/lib/special sprite.cpp,1.12,1.13 sprite.h,1.9,1.10
Brought to you by:
wkendrick
From: Ricardo C. <rm...@us...> - 2004-08-17 23:02:27
|
Update of /cvsroot/super-tux/supertux/lib/special In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31409/lib/special Modified Files: sprite.cpp sprite.h Log Message: Added next action to sprite. Index: sprite.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/special/sprite.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- sprite.cpp 16 Aug 2004 12:13:00 -0000 1.12 +++ sprite.cpp 17 Aug 2004 23:01:58 -0000 1.13 @@ -103,10 +103,12 @@ } void -Sprite::start_animation(int loops) +Sprite::start_animation(int loops, std::string next_act) { -animation_loops = loops; reset(); +animation_loops = loops; +if(!next_act.empty()) + next_action = next_act; } void @@ -115,6 +117,7 @@ frame = 0; last_tick = SDL_GetTicks(); animation_reversed = true; +next_action.clear(); } bool @@ -156,7 +159,14 @@ { // last case can happen when not used reverse_animation() frame = get_frames() - 1; if(animation_loops > 0) + { animation_loops--; + if(animation_loops == 0) + { + set_action(next_action); + start_animation(-1); + } + } if(fabsf(excedent) < get_frames()) frame += excedent; @@ -169,7 +179,14 @@ { frame = 0; if(animation_loops > 0) + { animation_loops--; + if(animation_loops == 0) + { + set_action(next_action); + start_animation(-1); + } + } if(excedent < get_frames()) frame += excedent; Index: sprite.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/special/sprite.h,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- sprite.h 14 Aug 2004 11:50:24 -0000 1.9 +++ sprite.h 17 Aug 2004 23:01:58 -0000 1.10 @@ -64,8 +64,9 @@ /* Start an animation -1 - for infinite 0 - stopped - 1,2,3 - one, two, three times... */ - void start_animation(int loops); + 1,2,3 - one, two, three times... + If next_act specified, that action will be used when animation ends. */ + void start_animation(int loops, std::string next_act = ""); /** Check if animation is stopped or not */ bool check_animation(); /** Reverse the animation */ @@ -116,6 +117,7 @@ Actions actions; Action* action; + std::string next_action; }; } //namespace SuperTux |