Skip to content

Commit

Permalink
fix: Label multiplicative opacity should use graphics opacity not tex…
Browse files Browse the repository at this point in the history
…t opacity
  • Loading branch information
eonarheim committed Sep 20, 2024
1 parent c6315eb commit 30abd37
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ are doing mtv adjustments during precollision.

### Fixed

- Fixed issue where `ex.Label` where setting the opacity of caused a multiplicative opacity effect when actor opacity set
- Fixed issue where the `ex.Loader` would have a low res logo on small configured resolution sizes
- Fixed issue where `ex.Gif` was not parsing certain binary formats correctly
- Fixed issue where the boot `ex.Loader` was removing pixelRatio override
Expand Down
4 changes: 2 additions & 2 deletions src/engine/Label.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ export class Label extends Actor {
}

public get opacity(): number {
return this._text.opacity;
return this.graphics.opacity;
}

public set opacity(opacity: number) {
this._text.opacity = opacity;
this.graphics.opacity = opacity;
}

private _spriteFont: SpriteFont;
Expand Down
11 changes: 11 additions & 0 deletions src/spec/LabelSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,15 @@ describe('A label', () => {
expect((sut as any)._spriteFont).toBe(spriteFont);
// expect(sut.spriteFont).toBe(spriteFont);
});

it('can have opacity set on the label and its the same as the graphics', () => {
const label = new ex.Label({
text: 'some text',
opacity: 0.75
});

expect(label.opacity).toEqual(label.graphics.opacity);
label.opacity = 0.25;
expect(label.opacity).toEqual(label.graphics.opacity);
});
});

0 comments on commit 30abd37

Please sign in to comment.