Exemple #1
0
void Sprite::playAnimation(s16 x, s16 y, u16 anim) {
	if(!m_animations[anim]->isPlaying) {
		resetAnimation(anim);
		startAnimation(anim);
		m_animations[anim]->isPlaying = true;
	}
	
	if(animationAtEnd(anim)) {
		resetAnimation(anim);
		startAnimation(anim);
	}
	
	u16 animToDraw = m_animations[anim]->tabAnim[(u16)(m_animations[anim]->timer.time() / m_animations[anim]->delay)];
	drawFrame(x, y, animToDraw);
}
Exemple #2
0
void Sprite::playAnimation(s16 x, s16 y, u16 anim) {
	// If the animation is not playing
	if(!m_animations[anim]->isPlaying) {
		resetAnimation(anim); // Reset animation timer
		startAnimation(anim); // Start animation timer
		m_animations[anim]->isPlaying = true; // Set isPlaying boolean to true
	}
	
	// If the animation is at end
	if(animationAtEnd(anim)) {
		resetAnimation(anim); // Reset animation timer
		startAnimation(anim); // Start animation timer
	}
	
	// This variable contains the number of the animation's frame to draw
	u16 animToDraw = m_animations[anim]->tabAnim[(u16)(m_animations[anim]->timer.time() / m_animations[anim]->delay)];
	drawFrame(x, y, animToDraw); // Draw the frame
}