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.
- Source:
Properties:
Name Type Description anglenumber Gets or sets the angle of rotation in degrees.
-
cameraOffset
-
- Source:
Properties:
Name Type Description cameraOffsetPhaser.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.
-
destroyPhase
-
- Source:
Properties:
Name Type Description destroyPhaseboolean True if this object is currently being destroyed.
-
exists
-
- Default Value:
- true
- Source:
Properties:
Name Type Description existsboolean If exists = false then the Text isn't updated by the core game loop.
-
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
- Source:
Properties:
Name Type Description fixedToCameraboolean Set to true to fix this Graphics to the Camera at its current world coordinates.
-
game
-
- Source:
Properties:
Name Type Description gamePhaser.Game A reference to the currently running Game.
-
name
-
- Source:
Properties:
Name Type Description namestring The user defined name given to this object.
-
type
-
- Source:
Properties:
Name Type Description typenumber The const type of this object.
-
world
-
- Source:
Properties:
Name Type Description worldPhaser.Point The world coordinates of this Sprite. This differs from the x/y coordinates which are relative to the Sprites container.
-
z
-
- Source:
Properties:
Name Type Description znumber 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.
Methods
-
destroy(destroyChildren)
-
Destroy this Graphics instance.
Parameters:
Name Type Argument Default Description destroyChildrenboolean <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 pointsArray.<Phaser.Point> An array of Phaser.Points that make up the three vertices of this triangle
cullboolean <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 verticesArray.<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
cullboolean <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: