June 2018
Beginner to intermediate
298 pages
7h 38m
English
Attach a script and define the member variables:
extends RigidBody2Dvar screensize = Vector2()var sizevar radiusvar scale_factor = 0.2
The Main script will handle spawning new rocks, both at the beginning of a level as well as the smaller rocks that will appear after a large one explodes. A large rock will have a size of 3 and break into rocks of size 2, and so on. The scale_factor is multiplied by size to set the sprite's scale, the collision radius, and so on. You can adjust it later to change how big each category of rock is.
All of this will be set by the start() method:
func start(pos, vel, _size): position = pos size = _size mass = 1.5 * size $Sprite.scale = Vector2(1, 1) * scale_factor * size radius = int($Sprite.texture.get_size().x ...
Read now
Unlock full access