Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add Scene specific background color #2861

Merged
merged 2 commits into from
Jan 1, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat: Add Scene specific background color
eonarheim committed Dec 31, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit cb066e33ab6a42bb3b9b93236f7f24cfdba77c3a
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).

### Added

- Added Scene specific background color
- Added ability to apply draw offset to `ex.IsometricMap` and `ex.Tilemap`
- Added `visibility` and `opacity` to `ex.IsometricMap`
- Added base elevation for `ex.IsometricMap` so multiple maps can sort correctly
3 changes: 2 additions & 1 deletion src/engine/Engine.ts
Original file line number Diff line number Diff line change
@@ -1274,7 +1274,8 @@ O|===|* >________________>\n\
return;
}

this.graphicsContext.backgroundColor = this.backgroundColor;
// Use scene background color if present, fallback to engine
this.graphicsContext.backgroundColor = this.currentScene.backgroundColor ?? this.backgroundColor;

this.currentScene.draw(this.graphicsContext, delta);

6 changes: 6 additions & 0 deletions src/engine/Scene.ts
Original file line number Diff line number Diff line change
@@ -33,6 +33,7 @@ import { OffscreenSystem } from './Graphics/OffscreenSystem';
import { ExcaliburGraphicsContext } from './Graphics';
import { PhysicsWorld } from './Collision/PhysicsWorld';
import { EventEmitter, EventKey, Handler, Subscription } from './EventEmitter';
import { Color } from './Color';

export type SceneEvents = {
initialize: InitializeEvent<Scene>,
@@ -75,6 +76,11 @@ implements CanInitialize, CanActivate<TActivationData>, CanDeactivate, CanUpdate
*/
public camera: Camera = new Camera();

/**
* Scene specific background color
*/
public backgroundColor?: Color;

/**
* The ECS world for the scene
*/