0 votes

extends Node2D

onready var tween = $BarTween
onready var Bar = $Bar

var Revealpos = Vector2(112,176)
var Hidepos = Vector2(112,208)

func onBarUIinputevent(viewport, event, shapeidx):
if event is InputEventMouseButton && Bar.position(112,176): <---- im i right writing this?
if event.ispressed() :
property(Bar, 'position', Revealpos, Hidepos,1.0,Tween.TRANSLINEAR, Tween.EASEIN_OUT )

the debugger write a "invalid call. Nonexistent function 'position in base 'Sprite'."

im trying to hide and reveal (Down n Up) a sprite box.

Godot version 3.2.1
in Engine by (62 points)

1 Answer

+1 vote
Best answer

position is a Property, not a Function. You're treating it like a function. With a property, you can set or get the value by simply reference in the property name.

So, to set it: Bar.position = Vector2(10,10)
To get the current value: var pos = Bar.position

It looks like you're trying to verify that the mouse button is pressed and the position of the sprite is very near a specific position. In that case, you might want to try something like:

if event is InputEventMouseButton && Bar.position.is_equal_approx(Vector2(112,176)):
by (10,894 points)
selected by

thank that is exactly what i was looking for.. but i have a little problem.. when it go down. it wont go up anymore.

func onBarUIinputevent(viewport, event, shapeidx):
if event is InputEventMouseButton :
if event.ispressed() && barBG.position.isequalapprox(Vector2(112,176)) :
tween.interpolateproperty(Bar, 'position', Revealpos, Hidepos,1.0,Tween.TRANSLINEAR, Tween.EASEINOUT )
if event.ispressed() && barBG.position.isequalapprox(Vector2(112,208)) :
tween.interpolateproperty(Bar, 'position', Hidepos, Revealpos,1.0,Tween.TRANSLINEAR, Tween.EASEINOUT )

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.