June 2018
Beginner to intermediate
298 pages
7h 38m
English
In the Rock scene, add an instance of Explosion and add this line to start():
$Explosion.scale = Vector2(0.75, 0.75) * size
This will ensure that the explosion is scaled to match the rock's size.
Add a signal called exploded at the top of the script, then add the explode() function, which will be called when the bullet hits the rock:
func explode(): layers = 0 $Sprite.hide() $Explosion/AnimationPlayer.play("explosion") emit_signal("exploded", size, radius, position, linear_velocity) linear_velocity = Vector2() angular_velocity = 0
The layers property ensures that the explosion will be drawn on top of the other sprites on the screen. Then, you will send a signal that will let Main know to spawn new rocks. This signal also needs ...
Read now
Unlock full access