diff --git a/CHANGELOG.md b/CHANGELOG.md index bf5c02a8a..aea52ec80 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Fixed +- Fixed Actor so it receives `predraw`/`postdraw` events per the advertised strongly typed events - Fixed infinite loop :bomb: when certain degenerate polygons were attempted to be triangulated! - Fixed incorrect type on `ex.Tilemap.getTileByPoint()` - Fixed TS type on `GraphicsComponent` and allow `.material` to be null to unset, current workaround is using `.material = null as any` diff --git a/src/engine/Graphics/GraphicsSystem.ts b/src/engine/Graphics/GraphicsSystem.ts index 07b21e6fe..b032182b0 100644 --- a/src/engine/Graphics/GraphicsSystem.ts +++ b/src/engine/Graphics/GraphicsSystem.ts @@ -13,6 +13,7 @@ import { ParallaxComponent } from './ParallaxComponent'; import { CoordPlane } from '../Math/coord-plane'; import { BodyComponent } from '../Collision/BodyComponent'; import { FontCache } from './FontCache'; +import { PostDrawEvent, PreDrawEvent } from '..'; export class GraphicsSystem extends System { public readonly types = ['ex.transform', 'ex.graphics'] as const; @@ -126,6 +127,7 @@ export class GraphicsSystem extends System { expect(animation.tick).toHaveBeenCalledWith(100, 2); }); + it('will receive predraw/postdraw', () => { + const predraw = jasmine.createSpy('predraw'); + const postdraw = jasmine.createSpy('postdraw'); + + const actor = new ex.Actor({ + name: 'events', + pos: ex.vec(100, 100), + width: 100, + height: 100, + color: ex.Color.Red + }); + + actor.events.on('predraw', predraw); + actor.events.on('postdraw', postdraw); + + scene.add(actor); + scene.draw(engine.graphicsContext, 100); + + expect(predraw).toHaveBeenCalledOnceWith(new ex.PreDrawEvent(engine.graphicsContext, 100, actor)); + expect(postdraw).toHaveBeenCalledOnceWith(new ex.PostDrawEvent(engine.graphicsContext, 100, actor)); + }); + it('can detect containment off of child actors', () => { const parent = new ex.Actor({ x: 600, y: 100, width: 100, height: 100 }); const child = new ex.Actor({ x: 0, y: 0, width: 100, height: 100 });