Adding HdpiManager to start and scale from a default resolution that is correct by default for the game.
Fixing VirtualJoystick on resize.
This commit is contained in:
parent
6a2326c4b3
commit
04d3cf8593
9 changed files with 213 additions and 32 deletions
32
front/tests/Phaser/Services/HdpiManagerTest.ts
Normal file
32
front/tests/Phaser/Services/HdpiManagerTest.ts
Normal file
|
@ -0,0 +1,32 @@
|
|||
import "jasmine";
|
||||
import {HdpiManager} from "../../../src/Phaser/Services/HdpiManager";
|
||||
|
||||
describe("Test HdpiManager", () => {
|
||||
it("should match screen size if size is too small.", () => {
|
||||
const hdpiManager = new HdpiManager(640*480);
|
||||
|
||||
const result = hdpiManager.getOptimalGameSize({ width: 320, height: 200 });
|
||||
expect(result.game.width).toEqual(320);
|
||||
expect(result.game.height).toEqual(200);
|
||||
expect(result.real.width).toEqual(320);
|
||||
expect(result.real.height).toEqual(200);
|
||||
});
|
||||
|
||||
it("should match multiple just above.", () => {
|
||||
const hdpiManager = new HdpiManager(640*480);
|
||||
|
||||
let result = hdpiManager.getOptimalGameSize({ width: 960, height: 600 });
|
||||
expect(result.game.width).toEqual(960);
|
||||
expect(result.game.height).toEqual(600);
|
||||
|
||||
result = hdpiManager.getOptimalGameSize({ width: 640 * 2 + 50, height: 480 * 2 + 50 });
|
||||
expect(result.game.width).toEqual(Math.ceil((640 * 2 + 50) / 2));
|
||||
expect(result.game.height).toEqual((480 * 2 + 50) / 2);
|
||||
|
||||
result = hdpiManager.getOptimalGameSize({ width: 640 * 3 + 50, height: 480 * 3 + 50 });
|
||||
expect(result.game.width).toEqual(Math.ceil((640 * 3 + 50) / 3));
|
||||
expect(result.game.height).toEqual(Math.ceil((480 * 3 + 50) / 3));
|
||||
expect(result.real.width).toEqual(result.game.width * 3);
|
||||
expect(result.real.height).toEqual(result.game.height * 3);
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue