Arc
Introduction¶
Arc shape, built-in game object of phaser.
- Author: Richard Davey
Usage¶
Create shape¶
var arc = scene.add.arc(x, y, radius, startAngle, endAngle, anticlockwise, fillColor);
// var arc = scene.add.arc(x, y, radius, startAngle, endAngle, anticlockwise, fillColor, fillAlpha);
Custom class¶
- Define class
class MyArc extends Phaser.GameObjects.Arc { constructor(scene, x, y, radius, startAngle, endAngle, anticlockwise, fillColor) { super(scene, x, y, radius, startAngle, endAngle, anticlockwise, fillColor); // ... scene.add.existing(this); } // ... // preUpdate(time, delta) {} }
scene.add.existing(gameObject)
: Adds an existing Game Object to this Scene.- If the Game Object renders, it will be added to the Display List.
- If it has a
preUpdate
method, it will be added to the Update List.
- Create instance
var arc = new MyArc(scene, x, y, radius, startAngle, endAngle, anticlockwise, fillColor);
Color¶
- Fill color
- Get
var color = arc.fillColor; var alpha = arc.fillAlpha;
- Set
arc.setFillStyle(color, alpha);
- Clear
arc.setFillStyle();
- Get
- Stroke color
- Get
var color = arc.strokeColor;
- Set
arc.setStrokeStyle(lineWidth, color, alpha);
- Clear
arc.setStrokeStyle();
- Get
No tint methods
Uses arc.setFillStyle(color, alpha)
to change color.
Alpha¶
- Get
var alpha = arc.alpha;
- Set
arc.setAlpha(alpha); // arc.alpha = alpha;
Angle¶
- Start angle, in degrees.
- Get
var startAngle = arc.startAngle;
- Set
or
arc.setStartAngle(startAngle); // arc.setStartAngle(startAngle, anticlockwise);
arc.startAngle = startAngle;
- Get
- End angle, in degrees.
- Get
var endAngle = arc.endAngle;
- Set
or
arc.seEndAngle(endAngle);
arc.endAngle = endAngle;
- Get
- Anticlockwise (
true
, orfalse
)- Get
var anticlockwise = arc.anticlockwise;
- Set
arc.anticlockwise = anticlockwise;
- Get
Radius¶
- Radius
- Get
var radius = arc.radius;
- Set
or
arc.setRadius(radius);
arc.radius = radius;
- Get
- Iterations: Increase this value for smoother arcs, at the cost of more polygons being rendered. Default is
0.01
- Get
var iterations = arc.iterations;
- Set
arc.iterations = iterations;
- Get
Display size¶
- Get
var width = arc.displayWidth; var height = arc.displayHeight;
- Set
or
arc.setDisplaySize(width, height);
arc.displayWidth = width; arc.displayHeight = height;
Other properties¶
See game object
Create mask¶
var mask = arc.createGeometryMask();
See mask
Shader effects¶
Support postFX effects
Note
No preFX effect support