示例#1
0
文件: Sprite.cpp 项目: dujodujo/ape
void Sprite::set_current_animation(const std::string& animation_name) {
	if(this->current_animation_name != animation_name) {
		SpriteAnimation* animation = current_animation_set.get_current_animation(animation_name);
		this->current_animation = animation;
		this->current_animation_name = animation_name;
		set_frame_delay(current_animation->get_frame_delay());
		set_current_frame(0);
	}
}
示例#2
0
文件: Sprite.cpp 项目: Arvek/SOLARME
/**
 * \brief Sets the current animation of the sprite.
 *
 * If the sprite is already playing another animation, this animation is interrupted.
 * If the sprite is already playing the same animation, nothing is done.
 *
 * \param animation_name name of the new animation of the sprite
 */
void Sprite::set_current_animation(const std::string& animation_name) {

  if (animation_name != this->current_animation_name || !is_animation_started()) {

    this->current_animation_name = animation_name;
    this->current_animation = animation_set.get_animation(animation_name);
    set_frame_delay(current_animation->get_frame_delay());

    set_current_frame(0, false);

    if (lua_context != NULL) {
      lua_context->sprite_on_animation_changed(*this, current_animation_name);
      lua_context->sprite_on_frame_changed(*this, current_animation_name, 0);
    }
  }
}