Is there anyway to instance a canvas item? (Vacuum game)

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

I am trying to create a game where the player vacuums up objects(2D). I figured out how to erase the part of the image that the player goes over, but not the entire image.

However once I instance the mess into the scene, the area that can be interacted with remains in the top left hand corner. I want to place several mess in each level.

Is there anyway to do this with a textureRect? What is the best node to use?

:bust_in_silhouette: Reply From: exuin

CanvasItems don’t have position properties. So you probably shouldn’t make the root node of your instanced scene a CanvasItem. You can use a TextureRect, but those are meant for UI elements. As for the best node to use - it depends on how the vacuum works. But if you use a Node2D or any of its children the root node of the scene will have a position property.

Thank you! It’s parented by a node2D. The node2D has the code to erase it(pixel_set, pixel_get, set to Color(0,0,0,0), but when I instance that scene in another scene, it will only recognize interaction (mouse click, area entered) in the top left hand corner where the textureRect exists in it’s original scene.

Any ideas?

Jedemand | 2021-03-16 18:29