Group actions
Introduction¶
Set properties of game objects, built-in methods of phaser.
- Author: Richard Davey
Usage¶
Call function¶
Phaser.Actions.Call(gameObjects, function(gameObject) {
}, scope);
Set any property¶
Phaser.Actions.PropertyValueSet(gameObjects, key, value, step, index, direction);
gameObjects
: An array of game objects.key
: The property to be updated.value
: The amount to be added to the property.step
: This is added to thevalue
amount, multiplied by the iteration counter.index
: An optional offset to start searching from within the items array.direction
:1
: from beginning to end.-1
: from end to beginning.
Phaser.Actions.PropertyValueInc(gameObjects, key, value, step, index, direction);
Phaser.Actions.SmootherStep(gameObjects, key, min, max, inc));
Phaser.Actions.SmoothStep(gameObjects, key, min, max, inc));
Phaser.Actions.Spread(gameObjects, key, min, max, inc));
Position¶
Phaser.Actions.SetX(gameObjects, value, step, index, direction);
Phaser.Actions.IncX(gameObjects, value, step, index, direction);
Phaser.Actions.SetY(gameObjects, value, step, index, direction);
Phaser.Actions.IncY(gameObjects, value, step, index, direction);
Phaser.Actions.SetXY(gameObjects, x, y, stepX, stepY, index, direction);
Phaser.Actions.IncXY(gameObjects, x, y, stepX, stepY, index, direction);
Shift position¶
Set the position of first game object to (x, y), others to the position of previous game object.
Phaser.Actions.ShiftPosition(gameObjects, x, y, direction, output);
Position on shape¶
Grid align¶
Phaser.Actions.GridAlign(gameObjects, {
width: -1,
height: -1,
cellWidth: 1,
cellHeight: 1,
position: Phaser.Display.Align.TOP_LEFT,
x: 0,
y: 0
});
width
: The width of the grid in items (not pixels). -1 means lay all items out horizontally, regardless of quantity.height
: The height of the grid in items (not pixels). -1 means lay all items out vertically, regardless of quantity.cellWidth
: The width of the cell, in pixels.cellHeight
: The height of the cell, in pixels.position
: The alignment position.0
, orPhaser.Display.Align.TOP_LEFT
1
, orPhaser.Display.Align.TOP_CENTER
2
, orPhaser.Display.Align.TOP_RIGHT
3
, orPhaser.Display.Align.LEFT_TOP
4
, orPhaser.Display.Align.LEFT_CENTER
5
, orPhaser.Display.Align.LEFT_BOTTOM
6
, orPhaser.Display.Align.CENTER
7
, orPhaser.Display.Align.RIGHT_TOP
8
, orPhaser.Display.Align.RIGHT_CENTER
9
, orPhaser.Display.Align.RIGHT_BOTTOM
10
, orPhaser.Display.Align.BOTTOM_LEFT
11
, orPhaser.Display.Align.BOTTOM_CENTER
12
, orPhaser.Display.Align.BOTTOM_RIGHT
x
,y
: Position of first item.
Line¶
Line :
var line = new Phaser.Geom.Line(x1, y1, x2, y2);
Phaser.Actions.PlaceOnLine(gameObjects, line);
// Phaser.Actions.PlaceOnLine(gameObjects, line, ease);
ease
:- A string
- A function object.
Phaser.Actions.RandomLine(gameObjects, line);
Circle¶
Circle :
var circle = new Phaser.Geom.Circle(x, y, radius);
Phaser.Actions.PlaceOnCircle(gameObjects, circle, startAngle, endAngle);
Phaser.Actions.RandomCircle(gameObjects, circle);
Ellipse¶
Ellipse :
var ellipse = new Phaser.Geom.Ellipse(x, y, width, height);
Phaser.Actions.PlaceOnEllipse(gameObjects, ellipse, startAngle, endAngle);
Triangle¶
Triangle :
var triangle = new Phaser.Geom.Triangle(x1, y1, x2, y2, x3, y3);
Phaser.Actions.PlaceOnTriangle(gameObjects, triangle, stepRate);
Phaser.Actions.RandomTriangle(gameObjects, triangle);
Rectangle¶
var rect = new Phaser.Geom.Rectangle(x, y, width, height);
Phaser.Actions.PlaceOnRectangle(gameObjects, rect, shift;
Phaser.Actions.RandomRectangle(gameObjects, rect);
Phaser.Actions.WrapInRectangle(gameObjects, rect, padding);
Angle¶
Phaser.Actions.Angle(gameObjects, value, step, index, direction);
// value: angle in radians
Phaser.Actions.Rotate(gameObjects, value, step, index, direction);
// value: angle in degree
Phaser.Actions.RotateAround(gameObjects, point, angle);
// point: {x, y}, angle: angle in radians
Phaser.Actions.RotateAroundDistance(gameObjects, point, angle, distance);
// point: {x, y}, angle: angle in radians
Visible¶
Phaser.Actions.SetVisible(gameObjects, value, index, direction);
Phaser.Actions.ToggleVisible(gameObjects);
Alpha¶
Phaser.Actions.SetAlpha(gameObjects, value, step, index, direction);
Tint¶
Phaser.Actions.setTint(gameObjects, value);
//Phaser.Actions.setTint(gameObjects, topLeft, topRight, bottomLeft, bottomRight);
Origin¶
Phaser.Actions.SetOrigin(gameObjects, originX, originY, stepX, stepY, index, direction);
Scale¶
Phaser.Actions.ScaleX(gameObjects, value, step, index, direction);
Phaser.Actions.ScaleY(gameObjects, value, step, index, direction);
Phaser.Actions.ScaleXY(gameObjects, x, y, stepX, stepY, index, direction);
Scroll factor¶
Phaser.Actions.SetScrollFactorX(gameObjects, value, step, index, direction);
Phaser.Actions.SetScrollFactorY(gameObjects, value, step, index, direction);
Phaser.Actions.SetScrollFactor(gameObjects, x, y, stepX, stepY, index, direction);
Depth¶
Phaser.Actions.SetDepth(gameObjects, value, step, index, direction);
Hit area¶
Phaser.Actions.SetHitArea(gameObjects, hitArea, hitAreaCallback);
Blend mode¶
Phaser.Actions.SetBlendMode(gameObjects, blendMode, index, direction);
blendMode
: Blend mode
Play animation¶
Phaser.Actions.PlayAnimation(gameObjects, key, ignoreIfPlaying);
Shuffle¶
Phaser.Actions.Shuffle(gameObjects);