Falborian

Members
  • Content count

    1
  • Joined

  • Last visited

  1. Trying to make smooth transition between the states (using Perplexing Technology tutorial), but it gets stuck at preload state: Here is how it looks: index.html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Da Game</title> <script type="text/javascript" src="js/phaser.min.js"></script> <script type='text/javascript' src="js/boot.js"></script> <script type='text/javascript' src="js/load.js"></script> <script type='text/javascript' src="js/menu.js"></script> <script type='text/javascript' src="js/play.js"></script> <script type='text/javascript' src="js/game.js"></script> </head> <body> </body> </html> game.js var game = new Phaser.Game(800, 600, Phaser.AUTO, ''); game.state.add('boot', bootState); game.state.add('preload', preloadState); game.state.add('menu', menuState); game.state.add('play', playState); game.state.start('boot'); boot.js var bootState = { create: function() { game.physics.startSystem(Phaser.Physics.ARCADE); game.state.start('preload'); } }; preload.js var preloadState = { preload: function() { var loadingLabel = game.add.text(80, 150, 'Loading...', {font: '30px Arial', fill: '#ffffff'}); game.load.image('envelope', 'assets/sprites/envelope.png'); game.load.image('title', 'assets/sprites/title.png'); game.load.image('helpButton', 'assets/sprites/helpbutton.png'); game.load.image('playButton', 'assets/sprites/playbutton.png'); game.load.spritesheet('dog', 'assets/sprites/dogsprite.png', 32, 32); game.load.spritesheet('player', 'assets/sprites/postman.png', 23, 43); }, create: function() { game.state.start('menu'); } }; menu.js var menuState = { create: function () { var nameLabel = game.add.text(80, 80, 'Lorem Ipsum game', {font: '50px Arial', fill: '#ffffff'}); var startLabel = game.add.text(80, 80, 'Lorem Ipsum game', 'press "W" key to start', {font: '25px Arial', fill: '#ffffff'}); var wKey = game.input.keyboard.addKey(Phaser.Keyboard.W); wKey.onDown.addOnce(this.start, this); }, start: function() { game.state.start('play'); } }; and play.js var playState = { create: function() { game.stage.backgroundColor = '#124184'; player = game.add.sprite((Math.random() * 777), (Math.random() * 557), 'player'); player.animations.add('left', [4, 5, 6, 7], 7, true); player.animations.add('right', [8, 9, 10, 11], 7, true); player.animations.add('up', [12, 13, 14, 15], 7, true); player.animations.add('down', [1, 2, 3], 7, true); game.physics.arcade.enable(player); for (var i = 0; i < 1;) { dog = game.add.sprite((Math.random() * 768), (Math.random() * 568), 'dog'); if (player.x - 32 < dog.x && dog.x < player.x + 23) { dog.kill(); i = 0; } else if (player.y - 32 < dog.y && dog.y < player.y + 43) { dog.kill(); i = 0; } else { i++; } } dog.animations.add('left', [3, 4, 5], 7, true); dog.animations.add('right', [6, 7, 8], 7, true); dog.animations.add('up', [9, 10, 11], 7, true); dog.animations.add('down', [0, 1, 2], 7, true); game.physics.arcade.enable(dog); envelope = game.add.sprite(((Math.random() * 714) + 50), ((Math.random() * 523) + 50), 'envelope'); envelope.scale.setTo(0.6, 0.6); cursors = game.input.keyboard.createCursorKeys(); player.body.collideWorldBounds = true; }, update: function() { } }; I have no idea what is the problem and why the game window gets stuck at preload state (with simple "Loading..." text I've put, not reacting to anything). What is the problem? Thanks for feedback in advance!