diff --git a/CHANGELOG.md b/CHANGELOG.md index 6967dcd56..f94ab7a4f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -64,6 +64,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Added +- Child `ex.Actor` inherits opacity of parents - `ex.Engine.timeScale` values of 0 are now supported - `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 diff --git a/src/engine/Graphics/GraphicsSystem.ts b/src/engine/Graphics/GraphicsSystem.ts index 3c323850c..23fa6ded2 100644 --- a/src/engine/Graphics/GraphicsSystem.ts +++ b/src/engine/Graphics/GraphicsSystem.ts @@ -141,7 +141,8 @@ export class GraphicsSystem extends System { } entity.events.emit('predraw', new PreDrawEvent(this._graphicsContext, elapsedMs, entity)); - this._graphicsContext.opacity *= graphics.opacity; + // this._graphicsContext.opacity *= graphics.opacity; + this._applyOpacity(entity); // Draw the graphics component this._drawGraphicsComponent(graphics, transform); @@ -269,4 +270,12 @@ export class GraphicsSystem extends System { } } } + + private _applyOpacity(entity: Entity): void { + const ancestors = entity.getAncestors(); + for (const ancestor of ancestors) { + const maybeGraphics = ancestor?.get(GraphicsComponent); + this._graphicsContext.opacity *= maybeGraphics?.opacity ?? 1; + } + } }