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
|
Brick
=====
The Brick component is used to create brick-like objects, or bricks endowed with scripting capabilities. This allows you to create elevators, conditional barriers (e.g., doors), movable platforms with custom trajectories, and much more.
The Brick component only affects collisions. The object that uses it is required to be an [entity](/engine/entity). **This component won't do any rendering.** Therefore, it's typically used in conjunction with the [Actor](/engine/actor) component.
*Example*
```
using SurgeEngine.Actor;
using SurgeEngine.Brick;
object "On/Off Platform" is "entity"
{
actor = Actor("On/Off Platform"); // for rendering
brick = Brick("On/Off Platform"); // for collision
state "main"
{
if(timeout(2.0)) {
brick.enabled = false;
actor.visible = false;
state = "disabled";
}
}
state "disabled"
{
if(timeout(2.0)) {
brick.enabled = true;
actor.visible = true;
state = "main";
}
}
}
```
Factory
-------
#### Brick
`Brick(spriteName)`
Spawns a new Brick component. Just like regular bricks, a Brick component has a collision mask associated with it. By default, the collision mask will be computed according to the animation 0 of the sprite named `spriteName`.
*Arguments*
* `spriteName`: string. The name of a sprite.
*Returns*
A new Brick component.
Properties
----------
#### enabled
`enabled`: boolean.
Whether the Brick component should affect collisions or not. Defaults to `true`.
#### type
`type`: string.
The type of the Brick component specifies how it affects collisions. This value must be either *"solid"* or *"cloud"*. Defaults to *"solid"*.
#### layer
`layer`: string.
Should the Brick component be tied to a specific layer? If so, which layer? This value must be one of the following: *"green"*, *"yellow"*, *"default"*. Defaults to *"default"*.
#### offset
`offset`: [Vector2](/engine/vector2) object.
A *(x,y)* offset relative to the parent object. Defaults to zero.
|