-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
3,727 additions
and
171 deletions.
There are no files selected for viewing
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Browser sync configuration file for the example project | ||
module.exports = { | ||
server: ['./example'], | ||
serveStatic: [ | ||
{ | ||
route: '/js', | ||
dir: [ | ||
'./dist', | ||
'./node_modules/phaser-ce/build' | ||
], | ||
}, | ||
], | ||
files: [ | ||
'./dist/index.js', | ||
'./example/**/*' | ||
], | ||
ghostMode: false, | ||
open: false, | ||
}; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'game', { preload: preload, create: create, update: update, render: render }); | ||
|
||
function preload() { | ||
game.stage.backgroundColor = '#007236'; | ||
game.load.image('mushroom', 'assets/sprites/mushroom2.png'); | ||
game.load.image('sonic', 'assets/sprites/sonic_havok_sanity.png'); | ||
game.load.image('phaser', 'assets/sprites/phaser1.png'); | ||
} | ||
|
||
var cursors; | ||
var logo1; | ||
var logo2; | ||
|
||
function create() { | ||
// game.plugins.add(new PhaserRuntimeEditor(game, game.root)); | ||
// Modify the world and camera bounds | ||
game.world.setBounds(-1000, -1000, 2000, 2000); | ||
|
||
for (var i = 0; i < 200; i++) { | ||
game.add.sprite(game.world.randomX, game.world.randomY, 'mushroom'); | ||
} | ||
|
||
game.add.text(0, 0, 'this text scrolls\nwith the background', { font: '32px Arial', fill: '#f26c4f', align: 'center' }); | ||
|
||
logo1 = game.add.sprite(0, 0, 'phaser'); | ||
logo1.fixedToCamera = true; | ||
logo1.cameraOffset.setTo(100, 100); | ||
|
||
logo2 = game.add.sprite(0, 0, 'phaser'); | ||
logo2.fixedToCamera = true; | ||
logo2.cameraOffset.setTo(500, 100); | ||
|
||
var t = game.add.text(0, 0, 'this text is fixed to the camera', { font: '32px Arial', fill: '#ffffff', align: 'center' }); | ||
t.fixedToCamera = true; | ||
t.cameraOffset.setTo(200, 500); | ||
|
||
game.add.tween(logo2.cameraOffset).to({ y: 400 }, 2000, Phaser.Easing.Back.InOut, true, 0, 2000, true); | ||
cursors = game.input.keyboard.createCursorKeys(); | ||
} | ||
|
||
function update() { | ||
if (cursors.up.isDown) game.camera.y -= 4; | ||
else if (cursors.down.isDown) game.camera.y += 4; | ||
|
||
if (cursors.left.isDown) game.camera.x -= 4; | ||
else if (cursors.right.isDown) game.camera.x += 4; | ||
} | ||
|
||
function render() { | ||
game.debug.cameraInfo(game.camera, 32, 32); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Example</title> | ||
<script src="/js/phaser.js"></script> | ||
<script src="/js/index.js"></script> | ||
</head> | ||
<body> | ||
<div id="game"></div> | ||
<script src="./game.js"></script> | ||
</body> | ||
</html> |
Oops, something went wrong.