Example #1
0
void VisibilityEnabler2D::_change_node_state(Node* p_node,bool p_enabled) {

	ERR_FAIL_COND(!nodes.has(p_node));

	{
		RigidBody2D *rb = p_node->cast_to<RigidBody2D>();
		if (rb) {

			if (p_enabled) {
				RigidBody2D::Mode mode = RigidBody2D::Mode(nodes[p_node].operator int());
				//rb->set_mode(mode);
				rb->set_sleeping(false);
			} else {
				//rb->set_mode(RigidBody2D::MODE_STATIC);
				rb->set_sleeping(true);
			}
		}
	}

	{
		AnimationPlayer *ap=p_node->cast_to<AnimationPlayer>();

		if (ap) {

			ap->set_active(p_enabled);
		}
	}

	{
		Particles2D *ps=p_node->cast_to<Particles2D>();

		if (ps) {

			ps->set_emitting(p_enabled);
		}
	}

}
void VisibilityEnabler2D::_change_node_state(Node* p_node,bool p_enabled) {

	ERR_FAIL_COND(!nodes.has(p_node));

	{
		RigidBody2D *rb = p_node->cast_to<RigidBody2D>();
		if (rb) {

			rb->set_sleeping(!p_enabled);
		}
	}

	{
		AnimationPlayer *ap=p_node->cast_to<AnimationPlayer>();

		if (ap) {

			ap->set_active(p_enabled);
		}
	}
	{
		AnimatedSprite *as=p_node->cast_to<AnimatedSprite>();

		if (as) {

			if (p_enabled)
				as->play();
			else
				as->stop();
		}
	}

	{
		Particles2D *ps=p_node->cast_to<Particles2D>();

		if (ps) {

			ps->set_emitting(p_enabled);
		}
	}

}