Skip to content

Commit

Permalink
fix: Loader suppressPlayButton is now respected
Browse files Browse the repository at this point in the history
  • Loading branch information
eonarheim committed May 5, 2024
1 parent 6adef00 commit 0f9e77d
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).

### Fixed

-
- Fixed issue where `ex.Loader.suppressPlayButton = true` did not work. Only using the `ex.Engine({suppressPlayButton: true})` worked

### Updates

Expand Down
1 change: 1 addition & 0 deletions sandbox/src/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ var boot = new ex.Loader();
// fullscreenAfterLoad: true,
// fullscreenContainer: document.getElementById('container')
// });
// boot.suppressPlayButton = true;
boot.addResource(heartImageSource);
boot.addResource(heartTex);
boot.addResource(imageRun);
Expand Down
2 changes: 1 addition & 1 deletion src/engine/Engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1804,7 +1804,7 @@ O|===|* >________________>\n\
this._hideLoader = hideLoader;

if (loader instanceof Loader) {
loader.suppressPlayButton = this._suppressPlayButton;
loader.suppressPlayButton = loader.suppressPlayButton || this._suppressPlayButton;
}
this._loader.onInitialize(this);

Expand Down
43 changes: 42 additions & 1 deletion src/spec/LoaderSpec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
import * as ex from '@excalibur';
import { ExcaliburMatchers, ensureImagesLoaded } from 'excalibur-jasmine';
import { ExcaliburAsyncMatchers, ExcaliburMatchers, ensureImagesLoaded } from 'excalibur-jasmine';
import { TestUtils } from './util/TestUtils';

describe('A loader', () => {
let engine: ex.Engine;

const reset = () => {
engine.stop();
engine.dispose();
engine = null;
(<any>window).devicePixelRatio = 1;
const playButton = document.getElementById('excalibur-play');
if (playButton) {
const body = playButton.parentNode.parentNode;
body.removeChild(playButton.parentNode);
}
};
beforeEach(() => {
jasmine.addMatchers(ExcaliburMatchers);
jasmine.addAsyncMatchers(ExcaliburAsyncMatchers);
engine = TestUtils.engine();
});

Expand Down Expand Up @@ -344,4 +357,32 @@ describe('A loader', () => {
fail();
});
});

it('should not show the play button when suppressPlayButton is turned on', (done) => {
reset();
engine = TestUtils.engine({ suppressPlayButton: false });
engine.currentScene.add(
new ex.Actor({
pos: new ex.Vector(250, 250),
width: 20,
height: 20,
color: ex.Color.Red
})
);

const testClock = engine.clock as ex.TestClock;
const loader = new ex.Loader([new ex.ImageSource('src/spec/images/SpriteSpec/icon.png')]);
loader.suppressPlayButton = true;

TestUtils.runToReady(engine, loader).then(() => {
// With suppress play there is another 500 ms delay in engine load()
testClock.step(1);
engine.graphicsContext.flush();
expectAsync(engine.canvas)
.toEqualImage('src/spec/images/EngineSpec/engine-suppress-play.png')
.then(() => {
done();
});
});
});
});

0 comments on commit 0f9e77d

Please sign in to comment.