void AnimatedSprite::set_frame(int p_frame) { if (!frames.is_valid()) { return; } if (frames->has_animation(animation)) { int limit = frames->get_frame_count(animation); if (p_frame>=limit) p_frame=limit-1; } if (p_frame<0) p_frame=0; if (frame==p_frame) return; frame=p_frame; _reset_timeout(); update(); _change_notify("frame"); emit_signal(SceneStringNames::get_singleton()->frame_changed); }
void AnimatedSprite::_set_playing(bool p_playing) { if (playing == p_playing) return; playing = p_playing; _reset_timeout(); set_process_internal(playing); }
void AnimatedSprite::set_speed_scale(float p_speed_scale) { float elapsed = _get_frame_duration() - timeout; speed_scale = MAX(p_speed_scale, 0.0f); // We adapt the timeout so that the animation speed adapts as soon as the speed scale is changed _reset_timeout(); timeout -= elapsed; }
void AnimatedSprite::set_animation(const StringName &p_animation) { if (animation == p_animation) return; animation = p_animation; _reset_timeout(); set_frame(0); _change_notify(); update(); }
void AnimatedSprite::set_sprite_frames(const Ref<SpriteFrames> &p_frames) { if (frames.is_valid()) frames->disconnect("changed", this, "_res_changed"); frames = p_frames; if (frames.is_valid()) frames->connect("changed", this, "_res_changed"); if (!frames.is_valid()) { frame = 0; } else { set_frame(frame); } _change_notify(); _reset_timeout(); update(); update_configuration_warning(); }