Add new components: ExplosiveComponent, FadeAwayComponent, FireEffectComponent, FlipComponent, GravityMotionComponent, LaunchComponent, and update PlatformMovement with LastDirection property
This commit is contained in:
36
scripts/components/FlipComponent.cs
Normal file
36
scripts/components/FlipComponent.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using Godot;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
public partial class FlipComponent : Node2D
|
||||
{
|
||||
[Export] public Sprite2D LeftEye { get; set; }
|
||||
[Export] public Sprite2D RightEye { get; set; }
|
||||
[Export] public PlatformMovement PlatformMovement { get; set; }
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
if (PlatformMovement == null) return;
|
||||
|
||||
var velocity = PlatformMovement.LastDirection;
|
||||
switch (velocity.X)
|
||||
{
|
||||
case < 0f:
|
||||
LeftEye.Frame = 1;
|
||||
RightEye.Frame = 1;
|
||||
LeftEye.FlipH = true;
|
||||
RightEye.FlipH = true;
|
||||
break;
|
||||
case > 0f:
|
||||
LeftEye.Frame = 1;
|
||||
RightEye.Frame = 1;
|
||||
LeftEye.FlipH = false;
|
||||
RightEye.FlipH = false;
|
||||
break;
|
||||
default:
|
||||
LeftEye.Frame = 0;
|
||||
RightEye.Frame = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user