# Class: Graphics

## Phaser. Graphics

Phaser.Graphics

#### new Graphics(game, x, y)

  Creates a new `Graphics` object.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `game` | Phaser.Game | Current game instance.
  `x` | number | X position of the new graphics object.
  `y` | number | Y position of the new graphics object.

  Source:
    - gameobjects/Graphics.js, line 17

### Members

#### angle

  Indicates the rotation of the Graphics, in degrees, from its original orientation. Values from 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation. Values outside this range are added to or subtracted from 360 to obtain a value within the range. For example, the statement player.angle = 450 is the same as player.angle = 90. If you wish to work in radians instead of degrees use the property Sprite.rotation instead.

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `angle` | number | Gets or sets the angle of rotation in degrees.

  Source:
    - gameobjects/Graphics.js, line 323

#### cameraOffset

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `cameraOffset` | Phaser.Point | If this object is fixedToCamera then this stores the x/y offset that its drawn at, from the top-left of the camera view.

  Source:
    - gameobjects/Graphics.js, line 58

#### destroyPhase

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `destroyPhase` | boolean | True if this object is currently being destroyed.

  Source:
    - gameobjects/Graphics.js, line 374

#### exists

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `exists` | boolean | If exists = false then the Text isn't updated by the core game loop.

  Default Value:
    - true
  Source:
    - gameobjects/Graphics.js, line 31

#### fixedToCamera

  An Graphics that is fixed to the camera uses its x/y coordinates as offsets from the top left of the camera. These are stored in Graphics.cameraOffset. Note that the cameraOffset values are in addition to any parent in the display list. So if this Graphics was in a Group that has x: 200, then this will be added to the cameraOffset.x

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `fixedToCamera` | boolean | Set to true to fix this Graphics to the Camera at its current world coordinates.

  Source:
    - gameobjects/Graphics.js, line 343

#### game

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `game` | Phaser.Game | A reference to the currently running Game.

  Source:
    - gameobjects/Graphics.js, line 25

#### name

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `name` | string | The user defined name given to this object.

  Source:
    - gameobjects/Graphics.js, line 37

#### type

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `type` | number | The const type of this object.

  Source:
    - gameobjects/Graphics.js, line 43

#### world

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `world` | Phaser.Point | The world coordinates of this Sprite. This differs from the x/y coordinates which are relative to the Sprites container.

  Source:
    - gameobjects/Graphics.js, line 53

#### z

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `z` | number | The z-depth value of this object within its Group (remember the World is a Group as well). No two objects in a Group can have the same z value.

  Source:
    - gameobjects/Graphics.js, line 48

### Methods

#### destroy(destroyChildren)

  Destroy this Graphics instance.

  ##### Parameters:

  Name | Type | Argument | Default | Description
  --- | --- | --- | --- | ---
  `destroyChildren` | boolean | <optional> | true | Should every child of this object have its destroy method called?

  Source:
    - gameobjects/Graphics.js, line 143

#### drawPolygon()

  /* Draws a {Phaser.Polygon} or a {PIXI.Polygon} filled

  Source:
    - gameobjects/Graphics.js, line 197

#### drawTriangle(points, cull)

  /* Draws a single {Phaser.Polygon} triangle from a {Phaser.Point} array

  ##### Parameters:

  Name | Type | Argument | Default | Description
  --- | --- | --- | --- | ---
  `points` | Array.<Phaser.Point> |  |  | An array of Phaser.Points that make up the three vertices of this triangle
  `cull` | boolean | <optional> | false | Should we check if the triangle is back-facing

  Source:
    - gameobjects/Graphics.js, line 215

#### drawTriangles(vertices, {indices=null}, cull)

  /* Draws {Phaser.Polygon} triangles

  ##### Parameters:

  Name | Type | Argument | Default | Description
  --- | --- | --- | --- | ---
  `vertices` | Array.<Phaser.Point> | Array.<number> |  |  | An array of Phaser.Points or numbers that make up the vertices of the triangles
  `{indices=null}` | Array.<number> |  |  | An array of numbers that describe what order to draw the vertices in
  `cull` | boolean | <optional> | false | Should we check if the triangle is back-facing

  Source:
    - gameobjects/Graphics.js, line 247

#### postUpdate()

  Automatically called by World.postUpdate.

  Source:
    - gameobjects/Graphics.js, line 128

#### preUpdate()

  Automatically called by World.preUpdate.

  Source:
    - gameobjects/Graphics.js, line 85

#### update()

  Override and use this function in your own custom objects to handle any update requirements you may have.

  Source:
    - gameobjects/Graphics.js, line 118