mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-11 03:05:54 +00:00
New player add method
This commit is contained in:
parent
83e8b9081c
commit
a235183c61
8 changed files with 116 additions and 58 deletions
|
|
@ -5,6 +5,11 @@ namespace Cirno.Scripts;
|
|||
public static class Tools
|
||||
{
|
||||
public static T CreateChild<T>(this Node2D node, PackedScene prefab) where T : Node2D
|
||||
{
|
||||
return CreateChild<T>(node, prefab, node.Position);
|
||||
}
|
||||
|
||||
public static T CreateChild<T>(this Node2D node, PackedScene prefab, Vector2 position) where T : Node2D
|
||||
{
|
||||
if (prefab == null) return null;
|
||||
var newInstance = prefab.Instantiate<T>();
|
||||
|
|
@ -12,7 +17,7 @@ public static class Tools
|
|||
// Need to use parent instead of owner because tilemap scenes have no owner
|
||||
//node.Owner.CallDeferred("add_child", newInstance);
|
||||
newInstance.Transform = node.GlobalTransform;
|
||||
newInstance.Position = node.Position;
|
||||
newInstance.Position = position;
|
||||
|
||||
return newInstance;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue