Retrieve a sprite's offset?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By 9BitStrider
:warning: Old Version Published before Godot 3 was released.
extends Node2D

onready var fps_label = get_node("FPSResult")
onready var offset_label = get_node("OffsetResult")
onready var player_debug = get_node("MegaMan")

func _ready():
	set_process(true)

func _process(delta):
	fps_label.set_text(str(OS.get_frames_per_second()))
	offset_label.set_text(str(get_offset("player_debug")))

The above returns the error: "Invalid Call. Nonexistent function ‘get_offset’ in ‘Node2D (world.gd)’

I thought I was grabbing the player’s node correctly. Any ideas?

:bust_in_silhouette: Reply From: avencherus

Node2D doesn’t have an offset, only nodes such as Sprite, Camera2D, ViewportSprite, CanvasLayer, etc. have that method.

You might have a Sprite as a child of your player, in that case you will want to go deeper “\MegaMan\Sprite”.

That worked. Thanks. I want to use the offset to animate the player teleporting in from the top of the frame. (Add 8 to Y offset until Y offset = 0). Here’s hoping that it works. :slight_smile:

9BitStrider | 2017-08-08 17:00