Interactions

This commit is contained in:
MaddoScientisto 2024-06-09 18:19:57 +02:00
commit abff2ea59e
19 changed files with 282 additions and 10 deletions

17
Scripts/Tools.cs Normal file
View file

@ -0,0 +1,17 @@
using Godot;
namespace Cirno.Scripts;
public static class Tools
{
public static T CreateChild<T>(this Node2D node, PackedScene prefab) where T : Node2D
{
if (prefab == null) return null;
var newInstance = prefab.Instantiate<T>();
node.Owner.CallDeferred("add_child", newInstance);
newInstance.Transform = node.GlobalTransform;
newInstance.Position = node.Position;
return newInstance;
}
}