Нажимная плита
This commit is contained in:
parent
aca884b891
commit
2e5d268f35
5 changed files with 108 additions and 4 deletions
|
@ -131,7 +131,6 @@ public partial class LivingArmor : CharacterBody2D
|
|||
|
||||
private void _OnLightExited(Area2D area)
|
||||
{
|
||||
GD.Print("Unlighted");
|
||||
if (area.GetParentOrNull<GameCamera>() is null)
|
||||
return;
|
||||
|
||||
|
|
49
scripts/entities/PressurePlate.cs
Normal file
49
scripts/entities/PressurePlate.cs
Normal file
|
@ -0,0 +1,49 @@
|
|||
using Godot;
|
||||
using System;
|
||||
|
||||
public partial class PressurePlate : Area2D
|
||||
{
|
||||
private bool _pressed = false;
|
||||
private int _onButton = 0;
|
||||
|
||||
private AnimatedSprite2D _sprite;
|
||||
// Called when the node enters the scene tree for the first time.
|
||||
public override void _Ready()
|
||||
{
|
||||
_sprite = (AnimatedSprite2D)FindChild("AnimatedSprite2D");
|
||||
}
|
||||
|
||||
// Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
}
|
||||
|
||||
public override void _PhysicsProcess(double delta)
|
||||
{
|
||||
if (_pressed)
|
||||
{
|
||||
_sprite.Play("pressed");
|
||||
}
|
||||
else
|
||||
{
|
||||
_sprite.Play("default");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void _onPressed(Node2D body)
|
||||
{
|
||||
_onButton += 1;
|
||||
_pressed = true;
|
||||
}
|
||||
|
||||
|
||||
private void _onUnpressed(Node2D body)
|
||||
{
|
||||
_onButton -= 1;
|
||||
if (_onButton > 0)
|
||||
return;
|
||||
_pressed = false;
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue