Hello. I am new in Godot, and developing a basic pixel art topview game for school.
Here, a character is moved on the screen and can collide with objects. There are 6 items (each item is a subscene), and as the character collides with each one of these items, a new scene appears, showing a specific text and a “Next” button.
And here is my issue: when I press “Next” button within the Text scene, the user should be taken to the main scene again, but the previously collided objects shouldn’t be there (like they were already “collected” before). And this should be the dynamics until the six elements are collected.
Can you guide me on how to make it work?
Now, the button just takes me to the main scene, and the elements remain there.
yes, if you change scene to file path, then you reset the scene essentially, to just trigger that text scene, you can add_child(text_scene) to the room on a CanvasLayer node, then remove it once it’s done, so you dont need to use change scene to file path and the room wont reset like you have now
Thank you. Looks better, but still stuck.
I added a CanvasLayer to the room scene - with the text scene - but it shows up as soon as I play the scene.
Is it possible to have the CanvasLayer invisible and the show up only when character collides?
CanvasLayer is just another Layer for your CanvasItems to draw at
in CanvasLayer you put your Text Scene. So when you collide with the item, instantiate and add_child the text scene to this CanvasLayer node. When you click next or continue button, destroy this Recently added Text Scene in CanvasLayer
make sure you only created a Text Scene per Collided item, to make sure it’s only 1 scene created, use a boolean to block any additional text scene creation
you indeed also only can toggle the visibility of Text Scene if you put the Text Scene before the game run, and just changing its text.
using
text_scene.visible=false
text_scene.visible=true