Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Syl |
Greets!
Got an area2D wich once triggered gives some results, amongst them the possible change of scene with a button pressed.
Following:
func _on_Area2D_body_entered(_body):
I’d need something like that:
if button_Enter_is_pressed:
get_tree().change_scene("res://Scenes/CCreation.tscn")
Any help?
So you want to have a button, that (once clicked) changes the current scene. But only after a body (Any body? Just the player?) entered a certain area? Should the button stop working after the body leaves that area again? Is the button inside the area?
njamster | 2020-02-24 12:13
Actually got one button on my GUI that should serve to change to scenes from my TileMap scene. On each tile there’s an area2d and its collisionshape when body entered/exited, triggering sprite/image, labels/description, audio/sounds, random events and so on.
Look: Imgur: The magic of the Internet
See the arrow to the right button? That should allow to enter the different adventures zones on special tile.
Here is the typical script of one of those collisionshape/tile: Imgur: The magic of the Internet
Trouble is, my button function only change scene to the last signaled/conected, always the same scene, whatever the scene name written in script. So i thought it best to be in the ‘on area2D entered’ function. But how?
And yes, once pressed, the scene should change, and there’s no more button.
Syl | 2020-02-24 12:44