-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from oliverbenns/phaser-3
Phaser 3
- Loading branch information
Showing
5 changed files
with
49 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,33 @@ | ||
import 'pixi'; | ||
import 'p2'; | ||
import 'phaser'; | ||
|
||
import pkg from '../package.json'; | ||
import pkg from '../node_modules/phaser/package.json'; | ||
|
||
// This is the entry point of your game. | ||
|
||
const width = 800; | ||
const height = 600; | ||
|
||
const config = { | ||
width: 800, | ||
height: 600, | ||
renderer: Phaser.AUTO, | ||
parent: '', | ||
state: { | ||
preload, | ||
create, | ||
}, | ||
transparent: false, | ||
antialias: true, | ||
physicsConfig: { arcade: true }, | ||
width, | ||
height, | ||
type: Phaser.AUTO, | ||
scene: { preload, create }, | ||
}; | ||
|
||
const game = new Phaser.Game(config); | ||
|
||
function preload() { | ||
this.game.load.image('study', 'assets/img/study.png'); | ||
this.load.image('study', 'assets/img/study.png'); | ||
} | ||
|
||
function create() { | ||
const { game } = this; | ||
const objects = [ | ||
game.add.text(game.world.centerX, game.world.centerY * 0.8, `Welcome to Phaser ${pkg.dependencies.phaser.substr(1)}`, { font: "bold 19px Arial", fill: "#fff" }), | ||
game.add.sprite(game.world.centerX, game.world.centerY * 1.2, 'study') | ||
]; | ||
const centerX = width / 2; | ||
const centerY = height / 2; | ||
const welcomeMessage = `Welcome to Phaser ${pkg.version}`; | ||
|
||
this.add.image(centerX, centerY * 1.2, 'study'); | ||
|
||
objects.forEach(obj => obj.anchor.setTo(0.5, 0.5)); | ||
this.add | ||
.text(centerX, centerY * 0.8, welcomeMessage, { font: "bold 19px Arial", fill: "#fff" }) | ||
.setOrigin(0.5, 0.5); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters