Tween effect not working - "method clear_shapes isn't declared in the current class"

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By samjmiller

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":

I get the error message “The method clear_shapes 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 clear_shapes() 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!!

:bust_in_silhouette: Reply From: Lopy

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.

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, clear_shapes crashes the game when I try to play it; it will only run if I comment out clear_shapes)

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,

func _on_gem_area_entered(area):
	if area.get_name() == 'player':
func _on_effect_tween_complete( object, key ):

Appreciate you!

samjmiller | 2021-02-19 17:10

Update! I figured it out.

This is what I needed instead of clear_shapes()

	shape_owner_clear_shapes( crash )

Thanks for your help Lopy!

samjmiller | 2021-02-19 22:55