Sets the points used by this Rope.
The points should be provided as an array of Vector2, or vector2-like objects (i.e. those with public x/y properties).
Each point corresponds to one segment of the Rope. The more points in the array, the more segments the rope has.
Point coordinates are given in local-space, not world-space, and are directly related to the size of the texture this Rope object is using.
For example, a Rope using a 512 px wide texture, split into 4 segments (128px each) would use the following points:
rope.setPoints([
{ x: 0, y: 0 },
{ x: 128, y: 0 },
{ x: 256, y: 0 },
{ x: 384, y: 0 }
]);
Or, you can provide an integer to do the same thing:
rope.setPoints(4);
Which will divide the Rope into 4 equally sized segments based on the frame width.
Note that calling this method with a different number of points than the Rope has currently will reset the color and alpha values, unless you provide them as arguments to this method.
name | type | arguments | Default | description |
---|---|---|---|---|
points | number | Array.<Phaser.Types.Math.Vector2Like> | <optional> | 2 |
An array containing the vertices data for this Rope, or a number that indicates how many segments to split the texture frame into. If none is provided a simple quad is created. |
colors | number | Array.<number> | <optional> |
Either a single color value, or an array of values. |
|
alphas | number | Array.<number> | <optional> |
Either a single alpha value, or an array of values. |
This Game Object instance.