Topic was automatically imported from the old Question2Answer platform.
Asked By
mabelair88
Tree:
SCRIPT:
Here is my first statement:
Creation of the instances:
When the user makes a mistake, I match the error number:
When the game stops:
When the user wants to replay the game:
My problem is: I am not able to hide the Sprite and disable the CollisionShape2d
I tried set_defered, free, queue_free nothing works.
Can you help me please.
Michel
Can You share images in other way ? A lot of antivruses block these
Inces | 2021-11-17 13:54
I do not have a webSite. I use DropBox to send images.
Michel
Since the images are not shown here is my data.
Tree: cloture.tscn
cloture (Type: node2D)
|__ k1 (Type: KinematicBody2D)
****|__ brun (Type: CollisionShape2d)
********|___ b1 (Type: Sprite)
SCRIPT: in game.tscn
###Here is my first statement:
var barreau1 = preload(“res://scenes/cloture.tscn”)
var barreau2 = preload(“res://scenes/cloture.tscn”)
###Creation of the instances:
k1 = barreau1.instance()
brun1 = k1.get_node(“k1/brun”)
b1 = k1.get_node(“k1/brun/b1”)
k2 = barreau2.instance()
brun2 = k2.get_node(“k2/brun”)
###When the user makes a mistake, I match the error number:
match compteur:
1:
$explosion.start()
brun1.set_deferred(“disabled”,true)
b1.visible = false
brun2.set_deferred(“disabled”,true)
b2.visible = false
2:
$explosion.start()
bleu3.set_deferred(“disabled”,true)
b3.visible = false
bleu4.set_deferred(“disabled”,true)
b4.visible = false
###In this routine I want to disable the CollisionShape2d and hide th Sprite
I am not able to hide the Sprite and disable the CollisionShape2d
I tried set_defered, free, queue_free nothing works.
Michel
Please cancel this question. I did solve the problem. Instead of preloading the scene, I instance my scene in the tree of my game.
Thank you Merlin1846. Now it is working fine.
Michel