/** * additional import for TypeScript * @import ResponseObject from "./../physics/response.js"; */ /** * Trigger an event when colliding with another object. * Supports both fade and mask-based transitions when loading a new level. * @category Game Objects */ export default class Trigger extends Renderable { /** * @param {number} x - the x coordinates of the trigger area * @param {number} y - the y coordinates of the trigger area * @param {Object} settings - trigger settings * @param {number} [settings.width] - width of the trigger area * @param {number} [settings.height] - height of the trigger area * @param {Rect[]|Polygon[]|Line[]|Ellipse[]} [settings.shapes] - collision shape(s) that will trigger the event * @param {number} [settings.duration] - Transition duration (in ms) * @param {string|Color} [settings.color] - Transition color (also accepts legacy `fade` property) * @param {string} [settings.transition="fade"] - Transition type: "fade" for a color fade, "mask" for a shape-based mask transition * @param {Ellipse|Polygon} [settings.shape] - Mask shape for "mask" transition type (e.g. an Ellipse for iris, a Polygon for diamond/star) * @param {string} [settings.event="level"] - the type of event to trigger (only "level" supported for now) * @param {string} [settings.to] - level to load if level trigger * @param {string|Container} [settings.container] - Target container. See {@link level.load} * @param {Function} [settings.onLoaded] - Level loaded callback. See {@link level.load} * @param {boolean} [settings.flatten] - Flatten all objects into the target container. See {@link level.load} * @param {boolean} [settings.setViewportBounds] - Resize the viewport to match the level. See {@link level.load} * @example * // fade transition (default) * world.addChild(new Trigger(x, y, { * shapes: [new Rect(0, 0, 100, 100)], * color: "#000", * duration: 250, * to: "mymap2", * })); * @example * // mask transition with iris (ellipse) shape * world.addChild(new Trigger(x, y, { * shapes: [new Rect(0, 0, 100, 100)], * transition: "mask", * shape: new Ellipse(0, 0, 1, 1), * color: "#000", * duration: 500, * to: "mymap2", * })); * @example * // mask transition with diamond polygon * world.addChild(new Trigger(x, y, { * shapes: [new Rect(0, 0, 100, 100)], * transition: "mask", * shape: new Polygon(0, 0, [ * { x: 0, y: -1 }, { x: 1, y: 0 }, * { x: 0, y: 1 }, { x: -1, y: 0 }, * ]), * color: "#000", * duration: 400, * to: "mymap2", * })); */ constructor(x: number, y: number, settings: { width?: number | undefined; height?: number | undefined; shapes?: Rect[] | Polygon[] | Line[] | Ellipse[] | undefined; duration?: number | undefined; color?: string | Color; transition?: string | undefined; shape?: Ellipse | Polygon; event?: string | undefined; to?: string | undefined; container?: string | Container; onLoaded?: Function | undefined; flatten?: boolean | undefined; setViewportBounds?: boolean | undefined; }); color: any; duration: number | undefined; transition: string; transitionShape: any; fading: boolean; type: any; id: any; gotolevel: string | undefined; triggerSettings: { event: string; }; bodyDef: { type: string; shapes: Rect[]; collisionType: number; collisionMask: number; isSensor: boolean; }; /** * @ignore */ getTriggerSettings(): { event: string; }; /** * Trigger this event. Override in subclasses to customize behavior. * @protected */ protected triggerEvent(): void; /** * Fire the trigger when an entity first enters the trigger zone. * Using `onCollisionStart` rather than `onCollision` so the event * runs exactly once per entry — under the legacy alias this would * fire every frame the entity was inside the trigger. */ onCollisionStart(): void; } import Renderable from "./renderable.js"; //# sourceMappingURL=trigger.d.ts.map