Trigger
class Trigger extends Renderable
trigger an event when colliding with another object
Constructor
new Trigger(x: number, y: number) → {}
world.addChild(new me.Trigger(
x, y, {
shapes: [new me.Rect(0, 0, 100, 100)],
"duration" : 250,
"color" : "#000",
"to" : "mymap2"
}
));
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
x | number |
the x coordinates of the trigger area |
||
y | number |
the y coordinates of the trigger area |
||
settings.width | number |
<optional> |
width of the trigger area |
|
settings.height | number |
<optional> |
height of the trigger area |
|
settings.shapes | Array<Rect> | Array<Polygon> | Array<Line> | Array<Ellipse> |
<optional> |
collision shape(s) that will trigger the event |
|
settings.duration | string |
<optional> |
Fade duration (in ms) |
|
settings.color | string | Color |
<optional> |
Fade color |
|
settings.event | string |
<optional> |
"level" |
the type of event to trigger (only "level" supported for now) |
settings.to | string |
<optional> |
level to load if level trigger |
|
settings.container | string | Container |
<optional> |
Target container. See level.load |
|
settings.onLoaded | Function |
<optional> |
Level loaded callback. See level.load |
|
settings.flatten | boolean |
<optional> |
Flatten all objects into the target container. See level.load |
|
settings.setViewportBounds | boolean |
<optional> |
Resize the viewport to match the level. See level.load |
Summary
Methods from Trigger
boolean |
|
|
Properties inherited from Renderable
number |
|
boolean |
|
Container | Entity |
|
ObservableVector2d |
|
boolean |
|
string |
|
Body |
|
Matrix2d |
|
number |
|
boolean |
|
string |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
Rect | RoundRect | Polygon | Line | Ellipse |
|
string |
|
Function |
|
Application |
|
ObservableVector3d |
|
GLShader |
|
Color |
|
boolean |
|
Properties inherited from Rect
Methods inherited from Renderable
Methods inherited from Rect
Rect |
|
Rect |
|
boolean |
|
Rect |
|
boolean |
|
boolean |
|
boolean |
|
Rect |
|
Rect |
|
Polygon |
|
Rect |
|
Methods inherited from Polygon
Array<number> |
|
boolean |
|
Polygon |
|
Polygon |
|
|
|
Polygon |
|
Polygon |
|
Polygon |
|
Public Methods
onCollision(response: ResponseObject, other: Renderable | Container | Entity | Sprite | NineSliceSprite) → {boolean}
onCollision callback, triggered in case of collision with this trigger
Name | Type | Description |
---|---|---|
response | ResponseObject |
the collision response object |
other | Renderable | Container | Entity | Sprite | NineSliceSprite |
the other renderable touching this one (a reference to response.a or response.b) |
Type | Description |
---|---|
boolean |
true if the object should respond to the collision (its position and velocity will be corrected) |