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 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
|
Actor
=====
The Actor component is used to associate a sprite to a target object. The target object is required to be an [entity](/engine/entity). It's recommended to use only one actor per entity.
Factory
-------
#### Actor
`Actor(sprite)`
Spawns a new Actor component with the given sprite name.
*Arguments*
* `sprite`: string. The name of the sprite (defined in the *sprites/* folder).
*Returns*
An Actor component.
*Example*
```cs
using SurgeEngine.Actor;
object "SurgeTest" is "entity"
{
// spawns an Actor with the SurgeTest sprite
actor = Actor("SurgeTest");
state "main"
{
}
}
```
Properties
----------
#### anim
`anim`: number.
A shortcut to `animation.id`: an integer corresponding to the animation number. Defaults to 0.
#### animation
`animation`: [Animation](/engine/animation) object, read-only.
Reference to the Animation object of the Actor.
#### entity
`entity`: object, read-only.
The entity associated with this component.
#### hflip
`hflip`: boolean.
Should the actor be flipped horizontally? Defaults to `false`.
#### vflip
`vflip`: boolean.
Should the actor be flipped vertically? Defaults to `false`.
#### visible
`visible`: boolean.
Should the actor be rendered? Defaults to `true`.
#### alpha
`alpha`: number.
Opacity value, ranging from zero (0% opaque) to one (100% opaque). Defaults to 1.0.
#### offset
`offset`: [Vector2](/engine/vector2) object.
A *(x,y)* offset relative to the parent object. Defaults to zero.
#### anchor
`anchor`: [Vector2](/engine/vector2) object.
A shortcut to `animation.anchor`. See also: [anchor](/engine/animation#anchor).
*Available since:* Open Surge 0.6.0
#### hotSpot
`hotSpot`: [Vector2](/engine/vector2) object.
A shortcut to `animation.hotSpot`. See also: [hot spot](/engine/animation#hotspot).
*Available since:* Open Surge 0.6.0. In versions prior to 0.6.0, you may get the hot spot using the [Animation](/engine/animation#hotspot) object.
#### actionSpot
`actionSpot`: [Vector2](/engine/vector2) object.
A shortcut to `animation.actionSpot`. See also: [action spot](/engine/animation#actionspot).
*Available since:* Open Surge 0.6.0
#### actionOffset
`actionOffset`: [Vector2](/engine/vector2) object, read-only.
A shortcut to `animation.actionOffset`. See also: [action offset](/engine/animation#actionoffset).
*Available since:* Open Surge 0.6.0
#### width
`width`: number, read-only.
The width of the actor.
#### height
`height`: number, read-only.
The height of the actor.
#### zindex
`zindex`: number.
Objects with greater zindex are rendered in front of others. Defaults to 0.5.
|