From fa62f5abad5be167aaba96d7132ef65fd91d5fab Mon Sep 17 00:00:00 2001 From: Erik Onarheim Date: Mon, 9 Sep 2024 09:10:35 -0500 Subject: [PATCH] fix: Allow actor args on Triggers --- CHANGELOG.md | 1 + src/engine/Trigger.ts | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 28f52386e..b7fdc4350 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -63,6 +63,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Added +- `ex.Trigger` now supports all valid actor constructor parameters from `ex.ActorArgs` in addition to `ex.TriggerOptions` - `ex.Gif` can now handle default embedded GIF frame timings - New `ex.Screen.worldToPagePixelRatio` API that will return the ratio between excalibur pixels and the HTML pixels. * Additionally excalibur will now decorate the document root with this same value as a CSS variable `--ex-pixel-ratio` diff --git a/src/engine/Trigger.ts b/src/engine/Trigger.ts index ae1d6f668..ee641350a 100644 --- a/src/engine/Trigger.ts +++ b/src/engine/Trigger.ts @@ -2,7 +2,7 @@ import { Vector } from './Math/vector'; import { ExitTriggerEvent, EnterTriggerEvent, CollisionEndEvent, CollisionStartEvent } from './Events'; import { CollisionType } from './Collision/CollisionType'; import { Entity } from './EntityComponentSystem'; -import { Actor, ActorEvents } from './Actor'; +import { Actor, ActorArgs, ActorEvents } from './Actor'; import { EventEmitter } from './EventEmitter'; export type TriggerEvents = ActorEvents & { @@ -62,8 +62,8 @@ export class Trigger extends Actor { /** * @param options Trigger options */ - constructor(options: Partial) { - super({ x: options.pos?.x, y: options.pos?.y, width: options.width, height: options.height }); + constructor(options: Partial & ActorArgs) { + super({ ...options }); this.filter = options.filter ?? (() => true); this.repeat = options.repeat ?? -1;