Звуковая подсистема, звуки шагов, музыка.
This commit is contained in:
parent
aa948eb252
commit
7ca54bdb38
15 changed files with 272 additions and 35 deletions
|
@ -69,6 +69,7 @@ public partial class Player : CharacterBody2D
|
|||
protected AnimatedSprite2D Sprite;
|
||||
protected PanelContainer ChatLog;
|
||||
protected Camera2D Camera;
|
||||
protected AudioCollection Footsteps;
|
||||
|
||||
private Vector2 _newPosition;
|
||||
private double _currentTransitionTime = 0;
|
||||
|
@ -82,6 +83,7 @@ public partial class Player : CharacterBody2D
|
|||
Sprite = (AnimatedSprite2D)FindChild("AnimatedSprite2D");
|
||||
ChatLog = (PanelContainer)FindChild("ChatLog");
|
||||
Camera = (Camera2D)FindChild("Camera2D");
|
||||
Footsteps = (AudioCollection)FindChild("Footsteps");
|
||||
}
|
||||
|
||||
public override void _PhysicsProcess(double delta)
|
||||
|
@ -118,6 +120,12 @@ public partial class Player : CharacterBody2D
|
|||
Vector2 direction = Input.GetVector("move_left", "move_right", "move_up", "move_down");
|
||||
if (direction != Vector2.Zero)
|
||||
{
|
||||
Footsteps.Play();
|
||||
// if (!Footsteps.IsPlaying())
|
||||
// {
|
||||
// // Footsteps.PitchScale = (float)GD.RandRange(0.5, 1.0);
|
||||
// Footsteps.Play();
|
||||
// }
|
||||
velocity.X = direction.X * Speed;
|
||||
Sprite.Play("walk");
|
||||
Sprite.FlipH = direction.X switch
|
||||
|
@ -129,6 +137,7 @@ public partial class Player : CharacterBody2D
|
|||
}
|
||||
else
|
||||
{
|
||||
// Footsteps.Stop();
|
||||
velocity.X = Mathf.MoveToward(Velocity.X, 0, Speed);
|
||||
Sprite.Play("default");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue