Sprite::Sprite(const std::string& id) : Displayable(), current_animation_set_id(id), current_animation_set(get_current_animation_set(id)), current_frame(-1), current_animation_direction(0), finished(false) { set_current_animation(current_animation_set.get_default_animation()); }
void AnimationPlayer::seek(float p_time, bool p_update) { if (!playback.current.from) { if (playback.assigned) set_current_animation(playback.assigned); ERR_FAIL_COND(!playback.current.from); } playback.current.pos = p_time; if (p_update) { _animation_process(0); } }
void AnimationPlayer::seek_delta(float p_time, float p_delta) { if (!playback.current.from) { if (playback.assigned) set_current_animation(playback.assigned); ERR_FAIL_COND(!playback.current.from); } playback.current.pos = p_time - p_delta; if (speed_scale != 0.0) p_delta /= speed_scale; _animation_process(p_delta); //playback.current.pos=p_time; }
/** * \brief Creates a sprite with the specified animation set. * \param id name of an animation set */ Sprite::Sprite(const std::string& id): Drawable(), lua_context(NULL), animation_set_id(id), animation_set(get_animation_set(id)), current_animation(NULL), current_direction(0), current_frame(-1), suspended(false), ignore_suspend(false), paused(false), finished(false), synchronize_to(NULL), intermediate_surface(NULL), blink_delay(0) { set_current_animation(animation_set.get_default_animation()); }
bool AnimationPlayer::_set(const StringName &p_name, const Variant &p_value) { String name = p_name; if (name.begins_with("playback/play")) { // bw compatibility set_current_animation(p_value); } else if (name.begins_with("anims/")) { String which = name.get_slicec('/', 1); add_animation(which, p_value); } else if (name.begins_with("next/")) { String which = name.get_slicec('/', 1); animation_set_next(which, p_value); } else if (p_name == SceneStringNames::get_singleton()->blend_times) { Array array = p_value; int len = array.size(); ERR_FAIL_COND_V(len % 3, false); for (int i = 0; i < len / 3; i++) { StringName from = array[i * 3 + 0]; StringName to = array[i * 3 + 1]; float time = array[i * 3 + 2]; set_blend_time(from, to, time); } } else return false; return true; }