7-13-25 3:38am
This commit is contained in:
@@ -5,17 +5,24 @@ public partial class Cue : Sprite2D
|
||||
{
|
||||
[Signal]
|
||||
public delegate void ShootEventHandler(Vector2 impulse);
|
||||
public float _power = 0.0f;
|
||||
public int _powerDirection = 1;
|
||||
|
||||
public override void _Process(double delta)
|
||||
public int _powerDirection = 1;
|
||||
public float _power = 0.0f, _maxPower = 8.0f;
|
||||
public ProgressBar _progressBar;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_progressBar = GetParent().GetNode<ProgressBar>("PowerBar");
|
||||
}
|
||||
|
||||
public override void _Process(double delta_)
|
||||
{
|
||||
Vector2 mousePosition = GetViewport().GetMousePosition();
|
||||
LookAt(mousePosition);
|
||||
if (Input.IsActionPressed("left_click"))
|
||||
{
|
||||
_power += 0.1f * _powerDirection;
|
||||
if (_power >= ((Main)GetParent())._maxPower)
|
||||
if (_power >= _maxPower)
|
||||
{
|
||||
_powerDirection = -1;
|
||||
}
|
||||
@@ -37,4 +44,21 @@ public partial class Cue : Sprite2D
|
||||
|
||||
}
|
||||
|
||||
public void HideCue()
|
||||
{
|
||||
SetProcess(false);
|
||||
Hide();
|
||||
_progressBar.Hide();
|
||||
}
|
||||
|
||||
public void ShowCue()
|
||||
{
|
||||
Ball cueBall = GetParent().GetNode<Ball>("CueBall");
|
||||
SetProcess(true);
|
||||
Position = cueBall.Position;
|
||||
_progressBar.Position = new Vector2(cueBall.Position.X - _progressBar.Size.X / 2, cueBall.Position.Y + _progressBar.Size.Y / 2);
|
||||
Show();
|
||||
_progressBar.Show();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user