0 votes

Hello everyone,

I am using this (admittedly very old) tutorial from Kids Can Code, trying to add a tween effect to gems when they get collected. I know the tutorial uses an old version of GDScript, but have been mostly successful in figuring out how to find and update errors from the outdated script.

But when I run this function:

func _on_gem_area_enter( area ):
    if area.get_name() == "player":
    emit_signal("gem_grabbed")
        clear_shapes()
        effect.start() 

I get the error message "The method clearshapes isn't declared in the current class," which crashes the game when I try to play it. I tried looking for that method in the documentation so I can declare it, but found no trace. If I replace clearshapes() with queue_free() the game will play normally and the gems will disappear upon collection, but the tween animation doesn't happen.

Any thoughts on how to make this tween behave?

Thanks so much for any help!!

Godot version 3.2.3
in Engine by (127 points)

1 Answer

0 votes
Best answer

I believe this would do something similar to setting monitoring and monitorable to false. You can also try to use queue_free() on your sprite and connecting the Tween's timeout signal to a queue_free in the Area2D.

by (2,478 points)
selected by

Thank you for this, but it doesn't appear to be helping - I just can't get any tween animation to happen!

Here's the full script attached to my gem scene. Is there something else I'm missing? (again, clearshapes crashes the game when I try to play it; it will only run if I comment out clearshapes)

extends Area2D

onready var effect = get_node("effect")
onready var sprite = get_node("Sprite")

signal gem_grabbed

func _ready():
    effect.interpolate_property(sprite, 'transform/scale',
        sprite.get_scale(), Vector2(4.0, 4.0), 0.3,
        Tween.TRANS_QUAD, Tween.EASE_OUT)


func _on_gem_area_entered(area):
    print(area.get_name())
    if area.get_name() == 'player':
        emit_signal("gem_grabbed")
        clear_shapes() 
        queue_free()

func _on_effect_tween_complete( object, key ):
        queue_free()

Appreciate you!

Update! I figured it out.

This is what I needed instead of clear_shapes()

    shape_owner_clear_shapes( crash )

Thanks for your help Lopy!

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.