Put animation settings in KartModel
This commit is contained in:
parent
3a3963bf8d
commit
93b6b96c2e
@ -138,6 +138,7 @@ KartModel::KartModel(bool is_master)
|
|||||||
m_animation_frame[i]=-1;
|
m_animation_frame[i]=-1;
|
||||||
m_animation_speed = 25;
|
m_animation_speed = 25;
|
||||||
m_current_animation = AF_DEFAULT;
|
m_current_animation = AF_DEFAULT;
|
||||||
|
m_play_non_loop = false;
|
||||||
} // KartModel
|
} // KartModel
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@ -682,11 +683,12 @@ void KartModel::finishedRace()
|
|||||||
/** Enables- or disables the end animation.
|
/** Enables- or disables the end animation.
|
||||||
* \param type The type of animation to play.
|
* \param type The type of animation to play.
|
||||||
*/
|
*/
|
||||||
void KartModel::setAnimation(AnimationFrameType type)
|
void KartModel::setAnimation(AnimationFrameType type, bool play_non_loop)
|
||||||
{
|
{
|
||||||
// if animations disabled, give up
|
// if animations disabled, give up
|
||||||
if (m_animated_node == NULL) return;
|
if (m_animated_node == NULL) return;
|
||||||
|
|
||||||
|
m_play_non_loop = play_non_loop;
|
||||||
m_current_animation = type;
|
m_current_animation = type;
|
||||||
if(m_current_animation==AF_DEFAULT)
|
if(m_current_animation==AF_DEFAULT)
|
||||||
{
|
{
|
||||||
@ -825,6 +827,12 @@ void KartModel::update(float dt, float distance, float steer, float speed)
|
|||||||
// If animations are disabled, stop here
|
// If animations are disabled, stop here
|
||||||
if (m_animated_node == NULL) return;
|
if (m_animated_node == NULL) return;
|
||||||
|
|
||||||
|
if (m_play_non_loop && m_animated_node->getLoopMode() == true)
|
||||||
|
{
|
||||||
|
m_play_non_loop = false;
|
||||||
|
this->setAnimation(AF_DEFAULT);
|
||||||
|
}
|
||||||
|
|
||||||
// Update the speed-weighted objects' animations
|
// Update the speed-weighted objects' animations
|
||||||
if (m_kart != NULL)
|
if (m_kart != NULL)
|
||||||
{
|
{
|
||||||
|
@ -207,9 +207,14 @@ private:
|
|||||||
|
|
||||||
/** True if this is the master copy, managed by KartProperties. This
|
/** True if this is the master copy, managed by KartProperties. This
|
||||||
* is mainly used for debugging, e.g. the master copies might not have
|
* is mainly used for debugging, e.g. the master copies might not have
|
||||||
* anything attached to it etc. */
|
* anything attached to it etc. */
|
||||||
bool m_is_master;
|
bool m_is_master;
|
||||||
|
|
||||||
|
/** True if the animation played is non-loop, which will reset to
|
||||||
|
* AF_DEFAULT after first loop ends. Mainly used in soccer mode for
|
||||||
|
* animation playing after scored. */
|
||||||
|
bool m_play_non_loop;
|
||||||
|
|
||||||
void loadWheelInfo(const XMLNode &node,
|
void loadWheelInfo(const XMLNode &node,
|
||||||
const std::string &wheel_name, int index);
|
const std::string &wheel_name, int index);
|
||||||
|
|
||||||
@ -306,7 +311,7 @@ public:
|
|||||||
AnimationFrameType getAnimation() { return m_current_animation; }
|
AnimationFrameType getAnimation() { return m_current_animation; }
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
/** Enables- or disables the end animation. */
|
/** Enables- or disables the end animation. */
|
||||||
void setAnimation(AnimationFrameType type);
|
void setAnimation(AnimationFrameType type, bool play_non_loop = false);
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
/** Sets the kart this model is currently used for */
|
/** Sets the kart this model is currently used for */
|
||||||
void setKart(AbstractKart* k) { m_kart = k; }
|
void setKart(AbstractKart* k) { m_kart = k; }
|
||||||
|
@ -93,8 +93,6 @@ void SoccerWorld::reset()
|
|||||||
}
|
}
|
||||||
else WorldStatus::setClockMode(CLOCK_CHRONO);
|
else WorldStatus::setClockMode(CLOCK_CHRONO);
|
||||||
|
|
||||||
m_animation_timer = 0.0f;
|
|
||||||
m_animation_showing_kart = -1;
|
|
||||||
m_can_score_points = true;
|
m_can_score_points = true;
|
||||||
m_red_goal = 0;
|
m_red_goal = 0;
|
||||||
m_blue_goal = 0;
|
m_blue_goal = 0;
|
||||||
@ -164,17 +162,6 @@ void SoccerWorld::update(float dt)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(isRaceOver() || isStartPhase()) && m_animation_showing_kart != -1)
|
|
||||||
{
|
|
||||||
m_animation_timer += dt;
|
|
||||||
if (m_animation_timer > 6.0f)
|
|
||||||
{
|
|
||||||
m_karts[m_animation_showing_kart]
|
|
||||||
->getKartModel()->setAnimation(KartModel::AF_BEGIN);
|
|
||||||
m_animation_timer = 0.0f;
|
|
||||||
m_animation_showing_kart = -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} // update
|
} // update
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -192,7 +179,6 @@ void SoccerWorld::onCheckGoalTriggered(bool first_goal)
|
|||||||
m_goal_sound->play();
|
m_goal_sound->play();
|
||||||
if (m_ball_hitter != -1)
|
if (m_ball_hitter != -1)
|
||||||
{
|
{
|
||||||
m_animation_showing_kart = m_ball_hitter;
|
|
||||||
ScorerData sd;
|
ScorerData sd;
|
||||||
sd.m_id = m_ball_hitter;
|
sd.m_id = m_ball_hitter;
|
||||||
sd.m_correct_goal = isCorrectGoal(m_ball_hitter, first_goal);
|
sd.m_correct_goal = isCorrectGoal(m_ball_hitter, first_goal);
|
||||||
@ -200,7 +186,13 @@ void SoccerWorld::onCheckGoalTriggered(bool first_goal)
|
|||||||
if (sd.m_correct_goal)
|
if (sd.m_correct_goal)
|
||||||
{
|
{
|
||||||
m_karts[m_ball_hitter]->getKartModel()
|
m_karts[m_ball_hitter]->getKartModel()
|
||||||
->setAnimation(KartModel::AF_WIN_START);
|
->setAnimation(KartModel::AF_WIN_START, true/* play_non_loop*/);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (!sd.m_correct_goal)
|
||||||
|
{
|
||||||
|
m_karts[m_ball_hitter]->getKartModel()
|
||||||
|
->setAnimation(KartModel::AF_LOSE_START, true/* play_non_loop*/);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (first_goal)
|
if (first_goal)
|
||||||
|
@ -66,10 +66,6 @@ private:
|
|||||||
float m_goal_timer;
|
float m_goal_timer;
|
||||||
int m_ball_hitter;
|
int m_ball_hitter;
|
||||||
|
|
||||||
/** Timer for win/lose animation showing after each goal*/
|
|
||||||
float m_animation_timer;
|
|
||||||
int m_animation_showing_kart;
|
|
||||||
|
|
||||||
/** Goals data of each team scored */
|
/** Goals data of each team scored */
|
||||||
int m_red_goal;
|
int m_red_goal;
|
||||||
int m_blue_goal;
|
int m_blue_goal;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user