示例#1
0
void AnimationTree::_notification(int p_what) {

	if (active && p_what == NOTIFICATION_INTERNAL_PHYSICS_PROCESS && process_mode == ANIMATION_PROCESS_PHYSICS) {
		_process_graph(get_physics_process_delta_time());
	}

	if (active && p_what == NOTIFICATION_INTERNAL_PROCESS && process_mode == ANIMATION_PROCESS_IDLE) {
		_process_graph(get_process_delta_time());
	}

	if (p_what == NOTIFICATION_EXIT_TREE) {
		_clear_caches();
		if (last_animation_player) {

			Object *player = ObjectDB::get_instance(last_animation_player);
			if (player) {
				player->disconnect("caches_cleared", this, "_clear_caches");
			}
		}
	} else if (p_what == NOTIFICATION_ENTER_TREE) {
		if (last_animation_player) {

			Object *player = ObjectDB::get_instance(last_animation_player);
			if (player) {
				player->connect("caches_cleared", this, "_clear_caches");
			}
		}
	}
}
示例#2
0
文件: timer.cpp 项目: KelinciFX/godot
void Timer::_notification(int p_what) {

	switch (p_what) {

		case NOTIFICATION_READY: {

			if (autostart) {
#ifdef TOOLS_ENABLED
				if (Engine::get_singleton()->is_editor_hint() && get_tree()->get_edited_scene_root() && (get_tree()->get_edited_scene_root() == this || get_tree()->get_edited_scene_root()->is_a_parent_of(this)))
					break;
#endif
				start();
				autostart = false;
			}
		} break;
		case NOTIFICATION_INTERNAL_PROCESS: {
			if (timer_process_mode == TIMER_PROCESS_PHYSICS || !is_processing_internal())
				return;
			time_left -= get_process_delta_time();

			if (time_left < 0) {
				if (!one_shot)
					time_left += wait_time;
				else
					stop();

				emit_signal("timeout");
			}

		} break;
		case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: {
			if (timer_process_mode == TIMER_PROCESS_IDLE || !is_physics_processing_internal())
				return;
			time_left -= get_physics_process_delta_time();

			if (time_left < 0) {
				if (!one_shot)
					time_left += wait_time;
				else
					stop();
				emit_signal("timeout");
			}

		} break;
	}
}
示例#3
0
void AnimationPlayer::_notification(int p_what) {

	switch (p_what) {

		case NOTIFICATION_ENTER_TREE: {

			if (!processing) {
				//make sure that a previous process state was not saved
				//only process if "processing" is set
				set_physics_process(false);
				set_process(false);
			}
			//_set_process(false);
			clear_caches();
		} break;
		case NOTIFICATION_READY: {

			if (!Engine::get_singleton()->is_editor_hint() && animation_set.has(autoplay)) {
				play(autoplay);
				_animation_process(0);
			}
		} break;
		case NOTIFICATION_INTERNAL_PROCESS: {
			if (animation_process_mode == ANIMATION_PROCESS_PHYSICS)
				break;

			if (processing)
				_animation_process(get_process_delta_time());
		} break;
		case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: {

			if (animation_process_mode == ANIMATION_PROCESS_IDLE)
				break;

			if (processing)
				_animation_process(get_physics_process_delta_time());
		} break;
		case NOTIFICATION_EXIT_TREE: {

			//stop_all();
			clear_caches();
		} break;
	}
}