1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
|
Circular Movement
=================
The Circular Movement [behavior](/engine/behavior) makes the associated [entity](/engine/entity) perform a circular orbit on the 2D plane. Its basic parameters are:
* A radius, given in pixels
* A movement rate, given in cycles per second
Other parameters include: a movement scale in both X and Y axes (making it an elliptic orbit), a flag telling whether the movement should be clockwise or not, and so on.
*Example*
```
//
// The example below shows how to make an entity move along
// a circle of 128 pixels of radius at a rate of 0.25 cycles
// per second (i.e., it takes one second to complete 25% of
// a cycle, or 4 seconds to complete a cycle)
//
using SurgeEngine.Actor;
using SurgeEngine.Vector2;
using SurgeEngine.Behaviors.CircularMovement;
object "Simple Ball" is "entity"
{
actor = Actor("Simple Ball");
movement = CircularMovement();
state "main"
{
movement.radius = 128;
movement.rate = 0.25;
//movement.scale = Vector2.up; // uncomment to move along the y-axis only
}
}
```
Factory
-------
#### Behaviors.CircularMovement
`CircularMovement()`
Spawns a CircularMovement.
*Returns*
A CircularMovement object.
Properties
----------
#### radius
`radius`: number.
The radius of the movement, in pixels.
#### rate
`rate`: number.
The rate of the movement, given in cycles per second.
#### clockwise
`clockwise`: boolean.
Indicates whether the movement is clockwise (`true`) or counterclockwise (`false`). Defaults to `false`.
#### scale
`scale`: [Vector2](/engine/vector2) object.
Specifies the scale of the movement in both X and Y axes. It is used to distort the circle. `Vector2(1, 1)` means no distortion (default).
#### center
`center`: [Vector2](/engine/vector2) object | `null`.
If not `null`, forces the center of the movement to be at a particular position in world space. Defaults to `null`.
#### phaseOffset
`phaseOffset`: number.
A value in degrees that offsets the current [phase](#phase). Defaults to zero (180 means opposite phase relative to zero).
#### phase
`phase`: number, read-only.
A value in degrees that indicates the current phase of the movement.
|