Box2D
This extension allows you to easily implement proper physics using a physics library called Box2D.
World
Adjust the physics of all sprites.
Choose a type of containment to keep sprites within the stage.
- Boxed stage: Keeps sprites from going off the bottom and sides.
- Open (with floor): Keeps sprites from going off the bottom.
- Open (no floor): Removes all boundaries; sprites can go wherever they want.
Change the direction and strength of gravity.
Move forward in time by one step. Run this in a loop to keep the physics going.
Set how much simulation steps is considered one second. Usually this should be project's framerate, but can also be used to slow down or speed up time.
You can get the current simulation rate with the (simulation rate) reporter.
Sprites
Manipulate individual sprites.
Make physics apply to this sprite. It can also collide with other sprites that have physics enabled.
- Enable for this costume: Enable physics only for the current sprite or clone.
- Enable for this circle: Enable physics for the current sprite or clone as if it were shaped like a circle.
- Enable for all sprites: Enable physics for all sprites.
Precision mode will make the sprite work extra hard to make sure it doesn't overlap with anything. Note that this can decrease performance and even cause the project to get stuck, so use with care.
Makes physics no longer apply to this sprite.
Make the sprite go to the specified location.
- In world: Relative to the center of the world.
- On stage: Relative to the center of the screen (if you've scrolled it).
- Relative: Relative to itself.
Set the velocity (speed) of the sprite to the specified value.
You can get the velocity of the current sprite with the (x velocity) and (y velocity) reporters.
Directly send the sprite flying in a certain direction, adding on to its current velocity.
Set the angular velocity (rotational speed) of the sprite to the specified value.
You can get the angular velocity of the current sprite with the (angular velocity) reporter.
Directly send the sprite spinning, adding on to its current angular (rotational) velocity.
Choose whether the sprite is fixed in place or can move around.
You can tell if the sprite is currently fixed in place with the (fixed?) reporter.
Set the sprite's density, which affects how heavy it is.
You can get the sprite's current density with the (density) reporter.
Set the sprite's roughness. Smoother settings make the sprite slipperier.
You can get the sprite's current friction with the (friction) reporter.
Set the sprite's bounciness.
You can get the sprite's current bounciness with the (bounce) reporter.
Returns what other sprites the sprite is touching. Also includes the edges of the stage.
If there are multiple sprites touching, it will return a comma-separated list of them.
Screen
Move the camera around the world.
Scroll to the desired location.
You can get the current screen position with the (x scroll) and (y scroll) reporters.
This will not affect the world boundaries set by the [setup stage] block.