optimize gear and energy

This commit is contained in:
Chris Cromer 2022-11-14 08:31:16 -03:00
parent 7f10c06a0a
commit e4ba3f9907
Signed by: cromer
GPG Key ID: FA91071797BEEEC2
2 changed files with 11 additions and 5 deletions

View File

@ -3,11 +3,11 @@ using System;
public class Energy : Area2D public class Energy : Area2D
{ {
Event eventBus; private Event _eventBus;
public override void _Ready() public override void _Ready()
{ {
eventBus = GetNode<Event>("/root/Event"); _eventBus = GetNode<Event>("/root/Event");
GetNode<AnimatedSprite>("AnimatedSprite").Play(); GetNode<AnimatedSprite>("AnimatedSprite").Play();
} }
@ -18,7 +18,7 @@ public class Energy : Area2D
SetCollisionLayerBit((int) Game.PhysicsLayer.Collectable, false); SetCollisionLayerBit((int) Game.PhysicsLayer.Collectable, false);
if (String.Equals(body.Name, "Player")) if (String.Equals(body.Name, "Player"))
{ {
eventBus.EmitSignal("EnergyCollected", 1); _eventBus.EmitSignal("EnergyCollected", 1);
} }
QueueFree(); QueueFree();
} }

View File

@ -2,9 +2,15 @@ using Godot;
public class Gear : Area2D public class Gear : Area2D
{ {
private Sprite _sprite;
public override void _Ready()
{
_sprite = GetNode<Sprite>("Sprite");
}
public override void _Process(float delta) public override void _Process(float delta)
{ {
Sprite sprite = GetNode<Sprite>("Sprite"); _sprite.Rotate(Mathf.Deg2Rad(2));
sprite.Rotate(Mathf.Deg2Rad(2));
} }
} }