diff --git a/DungeonShooting_Godot/src/framework/ActivityObject.cs b/DungeonShooting_Godot/src/framework/ActivityObject.cs
index 19cd46b..4580fb2 100644
--- a/DungeonShooting_Godot/src/framework/ActivityObject.cs
+++ b/DungeonShooting_Godot/src/framework/ActivityObject.cs
@@ -24,7 +24,6 @@
///
public CollisionShape2D Collision { get; }
-
///
/// 是否调用过 Destroy() 函数
///
@@ -32,6 +31,7 @@
private List> _components = new List>();
private bool initShadow;
+ private string _prevAnimation;
public ActivityObject(string scenePath)
{
@@ -74,8 +74,7 @@
///
/// 显示阴影
///
- /// 用于绘制的纹理
- public void ShowShadowSprite(Texture texture)
+ public void ShowShadowSprite()
{
if (!initShadow)
{
@@ -83,11 +82,26 @@
ShadowSprite.Material = ResourceManager.ShadowMaterial;
}
- ShadowSprite.Texture = texture;
+ var anim = AnimatedSprite.Animation;
+ if (_prevAnimation != anim)
+ {
+ //切换阴影动画
+ ShadowSprite.Texture = AnimatedSprite.Frames.GetFrame(anim, AnimatedSprite.Frame);
+ }
+
+ _prevAnimation = anim;
ShadowSprite.Visible = true;
}
///
+ /// 隐藏阴影
+ ///
+ public void HideShadowSprite()
+ {
+ ShadowSprite.Visible = false;
+ }
+
+ ///
/// 返回是否能与其他ActivityObject互动
///
/// 触发者
@@ -152,9 +166,22 @@
{
temp.Start();
}
+
temp.Update(delta);
}
}
+
+ if (ShadowSprite.Visible)
+ {
+ var anim = AnimatedSprite.Animation;
+ if (_prevAnimation != anim)
+ {
+ //切换阴影动画
+ ShadowSprite.Texture = AnimatedSprite.Frames.GetFrame(anim, AnimatedSprite.Frame);
+ }
+
+ _prevAnimation = anim;
+ }
}
public override void _PhysicsProcess(float delta)
@@ -170,6 +197,7 @@
{
temp.Start();
}
+
temp.PhysicsUpdate(delta);
}
}
diff --git a/DungeonShooting_Godot/src/game/common/NodeExtend.cs b/DungeonShooting_Godot/src/game/common/NodeExtend.cs
index 3e72dda..a94a1d2 100644
--- a/DungeonShooting_Godot/src/game/common/NodeExtend.cs
+++ b/DungeonShooting_Godot/src/game/common/NodeExtend.cs
@@ -86,7 +86,7 @@
var yf = MathUtils.RandRangeInt(60, 120);
var rotate = MathUtils.RandRangeInt(-360, -360);
weapon.Position = Vector2.Zero;
- return weapon.StartThrow(new Vector2(20, 20), startPos, startHeight, direction, xf, yf, rotate, weapon.WeaponSprite);
+ return weapon.StartThrow(new Vector2(20, 20), startPos, startHeight, direction, xf, yf, rotate);
//return weapon.StartThrow(new Vector2(20, 20), startPos, startHeight, direction, xf, yf, rotate, weapon.WeaponSprite);
}
@@ -108,7 +108,7 @@
return null;
}
- public static T StartThrow(this ActivityObject node, Vector2 size, Vector2 start, float startHeight, float direction, float xSpeed, float ySpeed, float rotate, Sprite shadowSprite) where T : ThrowComponent
+ public static T StartThrow(this ActivityObject node, Vector2 size, Vector2 start, float startHeight, float direction, float xSpeed, float ySpeed, float rotate) where T : ThrowComponent
{
T throwNode = node.GetComponent();
if (throwNode == null)
@@ -120,7 +120,7 @@
{
throwNode.StopThrow();
}
- throwNode.StartThrow(size, start, startHeight, direction, xSpeed, ySpeed, rotate, shadowSprite);
+ throwNode.StartThrow(size, start, startHeight, direction, xSpeed, ySpeed, rotate);
return throwNode;
}
}
\ No newline at end of file
diff --git a/DungeonShooting_Godot/src/game/item/throwObject/ThrowComponent.cs b/DungeonShooting_Godot/src/game/item/throwObject/ThrowComponent.cs
index 55194c9..c2b6fee 100644
--- a/DungeonShooting_Godot/src/game/item/throwObject/ThrowComponent.cs
+++ b/DungeonShooting_Godot/src/game/item/throwObject/ThrowComponent.cs
@@ -105,7 +105,7 @@
}
public virtual void StartThrow(Vector2 size, Vector2 start, float startHeight, float direction, float xSpeed,
- float ySpeed, float rotate, Sprite shadowSprite)
+ float ySpeed, float rotate)
{
_collisionShape2D.Disabled = false;
@@ -145,8 +145,8 @@
RoomManager.Current.SortRoot.AddChild(_kinematicBody2D);
}
//显示阴影
- ActivityObject.ShowShadowSprite(shadowSprite.Texture);
- ShadowSprite.Scale = shadowSprite.Scale;
+ ActivityObject.ShowShadowSprite();
+ ShadowSprite.Scale = AnimatedSprite.Scale;
}
///