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:

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:

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:

destroyPhase

Properties:
Name Type Description
destroyPhase boolean

True if this object is currently being destroyed.

Source:

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:

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:

game

Properties:
Name Type Description
game Phaser.Game

A reference to the currently running Game.

Source:

name

Properties:
Name Type Description
name string

The user defined name given to this object.

Source:

type

Properties:
Name Type Description
type number

The const type of this object.

Source:

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:

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:

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:

drawPolygon()

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

Source:

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:

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:

postUpdate()

Automatically called by World.postUpdate.

Source:

preUpdate()

Automatically called by World.preUpdate.

Source:

update()

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

Source:
Phaser Copyright © 2012-2014 Photon Storm Ltd.
Documentation generated by JSDoc 3.3.0-dev on Thu Jul 10 2014 20:19:03 GMT+0100 (BST) using the DocStrap template.