JavaScript
var game = new Phaser.Game(500, 340, Phaser.AUTO, '', {
preload: preload,
create: create,
update: update,
render: render
});
var button = null;
function preload() {
game.load.crossOrigin = 'anonymous';
game.load.image('wallV', 'http://imgur.com/rgeqODx.png');
game.load.image('wallH', 'http://imgur.com/9ElFSZR.png');
game.load.image('player', 'http://imgur.com/oS5Q1Jx.png');
}
function create() {
game.stage.backgroundColor = '#3498db';
game.physics.startSystem(Phaser.Physics.ARCADE);
wall = game.add.group();
game.physics.arcade.enable(wall);
wall.enableBody = true;
game.add.sprite(0, 0, 'wallV', 0, wall);
game.add.sprite(480, 0, 'wallV', 0, wall);
game.add.sprite(0, 0, 'wallH', 0, wall);
game.add.sprite(300, 0, 'wallH', 0, wall);
game.add.sprite(0, 320, 'wallH', 0, wall);
game.add.sprite(300, 320, 'wallH', 0, wall);
game.add.sprite(-100, 160, 'wallH', 0, wall);
game.add.sprite(400, 160, 'wallH', 0, wall);
var middleTop = game.add.sprite(100, 80, 'wallH', 0, wall);
middleTop.scale.setTo(1.5, 1);
var middleBottom = game.add.sprite(100, 240, 'wallH', 0, wall);
middleBottom.scale.setTo(1.5, 1);
player = game.add.sprite(game.world.centerX, game.world.centerY, 'player');
player.anchor.setTo(0.5, 0.5);
game.physics.arcade.enable(player);
player.body.gravity.y = 500;
cursors = game.input.keyboard.createCursorKeys();
// -- my own debug
text = game.add.text(game.world.centerX, game.world.centerY + 100, "Hello, world!", {
"fill": "white",
font: "bold 12pt Consolas",
});
text.anchor.set(0.5, 0.5)
// Note: This is what you need
wall.forEach(function (w) {
w.body.immovable = true;
});
//
var worldX = 1.0;
var worldY = 1.0;
this.game.input.mouse.mouseWheelCallback = mouseWheel;
var t = this.game.add.tween(this.game.world.scale);
function...