sprite.debug

Category:Sprites

The debug state of the sprite, true or false.

When your games have complex interactions between sprites or the mouse it is helpful to see in the display area the center of the sprite, the outline of the sprite's collider and the sprite's depth. If set to true, the sprite is shown with the outline of the collider, the depth, and center.

The default debug is false. All sprite properties can be both accessed and updated.

Examples

var sprite1 = createSprite(200, 200);
sprite1.debug = true;
sprite1.setCollider("rectangle", 0, 0, 50, 50);
var sprite2 = createSprite(50, 50);
sprite2.debug = true;
drawSprites();

Syntax

sprite.debug

Returns

The debug state of the sprite, true or false.

Tips

  • Sprites all have the same properties and you use the dot notation (combining the name of the sprite, followed by a dot, with the label of the property) to both access and update the property for that sprite.
  • Any changes to the properties of a sprite will not be seen until after drawSprites() is called.

Found a bug in the documentation? Let us know at documentation@code.org