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"
    }
));
Parameters:
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


Properties inherited from Rect

number
bottom
number
centerX
number
centerY
number
height
number
left
number
right
number
top
string
type = "Rectangle"
number
width

Properties inherited from Polygon

Array<Vector2d>
points

Public Methods


onCollision trigger.js:134
onCollision(response: ResponseObject, other: Renderable | Container | Entity | Sprite | NineSliceSprite) → {boolean}

onCollision callback, triggered in case of collision with this trigger

Parameters:
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)

Returns:
Type Description
boolean

true if the object should respond to the collision (its position and velocity will be corrected)

Protected Methods


triggerEvent trigger.js:106
protected triggerEvent() → {}

trigger this event


Powered by webdoc!