Cursor example
This commit is contained in:
@@ -2,9 +2,21 @@ class_name BattleCursor extends Control
|
||||
|
||||
@export var cursor:PackedScene
|
||||
|
||||
func setCursors(targets:Array[BattleSingleton.BattlePosition]) -> void:
|
||||
func setCursors(battleScene:BattleScene, targets:Array[BattleSingleton.BattlePosition]) -> void:
|
||||
clearCursors()
|
||||
|
||||
for target in targets:
|
||||
var fighterScene = battleScene.getFighterSceneAtPosition(target)
|
||||
if fighterScene == null:
|
||||
continue
|
||||
|
||||
var cursorInstance = cursor.instantiate()
|
||||
add_child(cursorInstance)
|
||||
|
||||
# Convert world position to screen space
|
||||
var screenPos = battleScene.get_viewport().get_camera_3d().unproject_position(fighterScene.global_transform.origin)
|
||||
cursorInstance.position = screenPos
|
||||
|
||||
func clearCursors() -> void:
|
||||
# Clear all children (cursors).
|
||||
for child in get_children():
|
||||
|
||||
Reference in New Issue
Block a user