Graphics - samme/phaser3-faq GitHub Wiki

A graphics game object is a dimensionless drawing surface. It works as a stack of drawing commands, much like parts of the Canvas API. Unlike with a textured game object (e.g., Image), there's no size limit, but complex graphics (many drawing commands) will take longer to render.

There are two basic uses:

  • You create a graphics object at (0, 0) and then draw anywhere in the game world, using world coordinates.
  • You create a graphics object at some world position, draw on it, and then possibly move, rotate, or scale it. A graphics game object has no size or origin; it's really more like a point that you draw around. Rotations and scaling happen from that point. If you want to make the graphics's position its "center", you need to draw shapes around the local coordinates (0, 0). For single, discrete shapes, you may find it more natural to use Shape game objects instead of Graphics, since they have an origin and size.