State handling done. Refactored the Game constructor a LOT. Now works from within closures, outside of them, with Phaser.State objects or normal Objects with the right functions inside. Also fixed some small bugs in PluginManager and various scope issues with RAF.

This commit is contained in:
Richard Davey
2013-08-29 07:06:16 +01:00
parent 3c8cd20b70
commit 4bbcc380c5
12 changed files with 558 additions and 475 deletions
+50
View File
@@ -0,0 +1,50 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var state = {
preload: function() {
console.log('state preload called');
game.load.image('rememberMe', 'assets/pics/remember-me.jpg');
game.load.text('copyright', 'assets/warning - copyright.txt');
},
create: function() {
console.log('state create called');
// Let's try adding an image to the DOM
document.body.appendChild(game.cache.getImage('rememberMe'));
// And some text
var para = document.createElement('pre');
para.innerHTML = game.cache.getText('copyright');
document.body.appendChild(para);
}
}
var game = new Phaser.Game();
// This method now works either from within a closure or not
game.switchState(state);
})();
</script>
</body>
</html>