Toolvito

Works on this device

Collision Box Editor

Open a sprite and draw collision boxes and circles on it, such as a body, a head and a hit area. Change every shape in a table, see which shapes overlap or stick out, and save the shapes as a JSON file. The picture is opened in this browser and is not uploaded.

Your sprite

PNG, JPEG, WebP, GIF or BMP, up to 50 MB and 8,192 pixels on a side. It is opened in this browser and is not uploaded.

In pixels. A picture sets its own size.

Shape to draw

Drag on the drawing to draw a shape, or drag a shape to move it. With the keyboard: put the focus on the drawing, move the cross with the arrow keys (hold Shift for 10 pixels), press Enter to start a shape and Enter again to finish it. Escape stops a shape.

Drawing area for collision shapes.

Shapes

No shapes yet.

The JSON file

Ready. Draw a shape or choose Try an example.

Your collision shapes

Shapes
Rectangles and circles
Outside the picture
Overlapping shapes

How to use the editor

  1. Open a picture of your sprite, or set the size of an empty drawing area. You can also choose Try an example.
  2. Choose Rectangle or Circle. Drag on the drawing to draw the shape: from corner to corner for a rectangle, from the centre outwards for a circle. Drag a shape to move it.
  3. With the keyboard, put the focus on the drawing, move the cross with the arrow keys (hold Shift for 10 pixels) and press Enter at the first corner (or the centre), then move and press Enter again. Escape stops a shape.
  4. Change the name, the group (such as hitbox or hurtbox) and the numbers of every shape in the table.
  5. Choose the coordinates of the file, then Download JSON.

How the shapes are worked out

  • A rectangle from two corners: x and y are the smaller of the two, the width and height the differences.
  • A circle from its centre and a point on its edge: the radius is the distance √(dx² + dy²).
  • Two shapes overlap when they share some area. For a circle and a rectangle the page finds the point of the rectangle nearest to the centre of the circle. Shapes that only touch do not overlap.
  • In the file, pixels are measured from the top left corner with y down. Units from a pivot are (x − pivot x) ÷ pixels per unit across and (pivot y − y) ÷ pixels per unit up; a rectangle is then given by its bottom left corner and its centre.

Worked example

The example fighter is 64 × 64 pixels. Its body is a rectangle at 20, 24, 24 × 32 pixels, so its centre is at 32, 40. Its head is a circle at 32, 15 with a radius of 9; it touches the body at 32, 24 but does not overlap it. The punch at 42, 30, 18 × 8 pixels overlaps the body by 2 pixels.

With the pivot at 32, 64 (the feet) and 16 pixels per unit, the body is at x = (20 − 32) ÷ 16 = −0.75 and y = (64 − 56) ÷ 16 = 0.5 units, 1.5 units wide and 2 units high.

Limits you should know

  • Up to 200 shapes. Rectangles do not rotate. One picture at a time: for each frame of a sprite sheet, save a file of its own.
  • Pictures up to 8,192 pixels on a side and 50 MB.
  • The JSON file has a layout of its own, described in the file. Check what your game engine expects, and convert the numbers if needed.

Related tools