Version 0.7 release. StageScaleMode support added and world input values exposed.

This commit is contained in:
Richard Davey
2013-04-14 02:31:00 +01:00
parent 0541e93db4
commit ebf83609ae
18 changed files with 9289 additions and 271 deletions
+17 -11
View File
@@ -1,31 +1,37 @@
/// <reference path="../../Phaser/Game.ts" />
/// <reference path="../../Phaser/Sprite.ts" />
(function () {
var myGame = new Game(this, 'game', 800, 600, init, create, update);
// Here we create a quite tiny game (320x240 in size)
var myGame = new Game(this, 'game', 320, 240, init, create, update);
function init() {
// This sets a limit on the up-scale
myGame.stage.maxScaleX = 640;
myGame.stage.maxScaleY = 480;
// Then we tell Phaser that we want it to scale up to whatever the browser can handle, but to do it proportionally
myGame.stage.scaleMode = StageScaleMode.SHOW_ALL;
myGame.loader.addImageFile('melon', 'assets/sprites/melon.png');
myGame.loader.load();
}
function create() {
myGame.world.width = 3000;
myGame.world.height = 3000;
myGame.world.setSize(2000, 2000);
for(var i = 0; i < 1000; i++) {
myGame.createSprite(Math.random() * 3000, Math.random() * 3000, 'melon');
myGame.createSprite(myGame.world.randomX, myGame.world.randomY, 'melon');
}
myGame.stage.clear = true;
myGame.onRenderCallback = render;
}
function update() {
myGame.stage.context.fillStyle = 'rgb(255,255,255)';
myGame.stage.context.fillText('x: ' + myGame.input.x + ' y: ' + myGame.input.y, 10, 20);
if(myGame.input.keyboard.isDown(Keyboard.LEFT)) {
myGame.camera.x -= 4;
myGame.camera.scroll.x -= 4;
} else if(myGame.input.keyboard.isDown(Keyboard.RIGHT)) {
myGame.camera.x += 4;
myGame.camera.scroll.x += 4;
}
if(myGame.input.keyboard.isDown(Keyboard.UP)) {
myGame.camera.y -= 4;
myGame.camera.scroll.y -= 4;
} else if(myGame.input.keyboard.isDown(Keyboard.DOWN)) {
myGame.camera.y += 4;
myGame.camera.scroll.y += 4;
}
}
function render() {
myGame.input.renderDebugInfo(16, 16);
}
})();
+21 -12
View File
@@ -3,10 +3,17 @@
(function () {
var myGame = new Game(this, 'game', 800, 600, init, create, update);
// Here we create a quite tiny game (320x240 in size)
var myGame = new Game(this, 'game', 320, 240, init, create, update);
function init() {
// This sets a limit on the up-scale
myGame.stage.maxScaleX = 640;
myGame.stage.maxScaleY = 480;
// Then we tell Phaser that we want it to scale up to whatever the browser can handle, but to do it proportionally
myGame.stage.scaleMode = StageScaleMode.SHOW_ALL;
myGame.loader.addImageFile('melon', 'assets/sprites/melon.png');
myGame.loader.load();
@@ -15,41 +22,43 @@
function create() {
myGame.world.width = 3000;
myGame.world.height = 3000;
myGame.world.setSize(2000, 2000);
for (var i = 0; i < 1000; i++)
{
myGame.createSprite(Math.random() * 3000, Math.random() * 3000, 'melon');
myGame.createSprite(myGame.world.randomX, myGame.world.randomY, 'melon');
}
myGame.stage.clear = true;
myGame.onRenderCallback = render;
}
function update() {
myGame.stage.context.fillStyle = 'rgb(255,255,255)';
myGame.stage.context.fillText('x: ' + myGame.input.x + ' y: ' + myGame.input.y, 10, 20);
if (myGame.input.keyboard.isDown(Keyboard.LEFT))
{
myGame.camera.x -= 4;
myGame.camera.scroll.x -= 4;
}
else if (myGame.input.keyboard.isDown(Keyboard.RIGHT))
{
myGame.camera.x += 4;
myGame.camera.scroll.x += 4;
}
if (myGame.input.keyboard.isDown(Keyboard.UP))
{
myGame.camera.y -= 4;
myGame.camera.scroll.y -= 4;
}
else if (myGame.input.keyboard.isDown(Keyboard.DOWN))
{
myGame.camera.y += 4;
myGame.camera.scroll.y += 4;
}
}
function render() {
myGame.input.renderDebugInfo(16, 16);
}
})();