API Docs for: 3
Show:

World Class

Defined in: v3/p5play.js:5323

Look at the World reference pages before reading these docs.

https://p5play.org/learn/world.html

A world object is created automatically by p5play. There can only be one world per p5.js instance.

This class extends planck.World and adds some p5play specific features.

Constructor

World

()

Defined in v3/p5play.js:5323

Methods

getSpriteAt

(
  • x
  • y
)
Sprite

Defined in v3/p5play.js:5517

Returns the sprite at the top most layer position where the mouse click occurs

Parameters:

  • x Number
  • y Number

Returns:

Sprite:

a sprite

getSpritesAt

(
  • x
  • y
)
Array

Defined in v3/p5play.js:5479

Returns the sprites at a position.

Parameters:

  • x Number
  • y Number

Returns:

Array:

an array of sprites

step

(
  • timeStep
  • velocityIterations
  • positionIterations
)

Defined in v3/p5play.js:5454

Performs a physics simulation step that advances all sprites' forward in time by 1/60th of a second if no timeStep is given.

This function is automatically called at the end of the p5.js draw loop, unless it was already called inside the draw loop.

Parameters:

  • timeStep Number
    • time step in seconds
  • velocityIterations Number
  • positionIterations Number

Properties

allowSleeping

Boolean

Defined in v3/p5play.js:5646

"Sleeping" sprites get temporarily ignored during physics simulation. A sprite starts "sleeping" when it stops moving and doesn't collide with anything that it wasn't already touching.

This is a performance optimization that can be disabled for every sprite in the world.

Default: true

gravity.x

Unknown

Defined in v3/p5play.js:5373

Gravity force that affects all dynamic physics colliders.

gravity.y

Unknown

Defined in v3/p5play.js:5378

Gravity force that affects all dynamic physics colliders.

offset.x

Unknown

Defined in v3/p5play.js:5349

offset.y

Unknown

Defined in v3/p5play.js:5359

velocityThreshold

Number

Defined in v3/p5play.js:5413

The lowest velocity an object can have before it is considered to be at rest.

Adjust the velocity threshold to allow for slow moving objects but don't have it be too low, or else objects will never sleep.

Default: 0.19