feat: improved freeze-frame implementation
This commit is contained in:
parent
200ae37c3e
commit
4238abaecb
1 changed files with 6 additions and 2 deletions
|
|
@ -22,10 +22,11 @@ void PlayerCamera::end_effect() {
|
|||
if (this->active_environment.is_valid()) {
|
||||
this->active_environment->set_ambient_light_color(this->ambient_light_color);
|
||||
}
|
||||
Engine::get_singleton()->set_time_scale(1.0);
|
||||
get_tree()->set_pause(false);
|
||||
set_process(false);
|
||||
set_global_position(get_global_position() - this->shake_offset);
|
||||
this->shake_offset = {};
|
||||
this->active_environment->set_ambient_light_energy(1.f);
|
||||
}
|
||||
|
||||
void PlayerCamera::process(double delta) {
|
||||
|
|
@ -49,6 +50,7 @@ void PlayerCamera::_notification(int what) {
|
|||
default:
|
||||
return;
|
||||
case NOTIFICATION_ENTER_TREE:
|
||||
set_process_mode(ProcessMode::PROCESS_MODE_ALWAYS);
|
||||
instance = this;
|
||||
return;
|
||||
case NOTIFICATION_READY:
|
||||
|
|
@ -74,11 +76,13 @@ PlayerCamera *PlayerCamera::get_instance() {
|
|||
|
||||
Ref<SceneTreeTimer> PlayerCamera::impact_effect(Color color, float freeze_time, float zoom, float shake_intensity) {
|
||||
this->active_environment->set_ambient_light_color(color);
|
||||
Engine::get_singleton()->set_time_scale(0.000001);
|
||||
this->active_environment->set_ambient_light_energy(1.f);
|
||||
Ref<SceneTreeTimer> timer{ get_tree()->create_timer(freeze_time, true, false, true) };
|
||||
timer->set_process_always(true);
|
||||
timer->connect("timeout", callable_mp(this, &self_type::end_effect));
|
||||
this->active_shake += shake_intensity;
|
||||
++this->active_effects;
|
||||
get_tree()->set_pause(true);
|
||||
set_process(true);
|
||||
return timer;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue