mirror of
https://github.com/wassname/phaser.git
synced 2026-08-10 12:30:48 +08:00
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:
@@ -0,0 +1,53 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>phaser.js - a new beginning</title>
|
||||
<?php
|
||||
require('js.php');
|
||||
?>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
// Your game will work either from within a closure or not, it doesn't matter
|
||||
(function () {
|
||||
|
||||
// These are all optional parameters now
|
||||
var game = new Phaser.Game();
|
||||
|
||||
// In this approach we're simply using functions in the current scope to do what we need
|
||||
game.launch(this, preload, create);
|
||||
|
||||
function preload() {
|
||||
|
||||
console.log('*** preload called');
|
||||
|
||||
game.load.image('cockpit', 'assets/pics/cockpit.png');
|
||||
game.load.image('rememberMe', 'assets/pics/remember-me.jpg');
|
||||
game.load.image('overdose', 'assets/pics/lance-overdose-loader_eye.png');
|
||||
game.load.text('copyright', 'assets/warning - copyright.txt');
|
||||
|
||||
}
|
||||
|
||||
function create() {
|
||||
|
||||
console.log('*** create called');
|
||||
|
||||
// Let's try adding an image to the DOM
|
||||
document.body.appendChild(game.cache.getImage('cockpit'));
|
||||
document.body.appendChild(game.cache.getImage('overdose'));
|
||||
|
||||
// And some text
|
||||
var para = document.createElement('pre');
|
||||
para.innerHTML = game.cache.getText('copyright');
|
||||
document.body.appendChild(para);
|
||||
|
||||
}
|
||||
|
||||
/})();
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,55 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>phaser.js - a new beginning</title>
|
||||
<?php
|
||||
require('js.php');
|
||||
?>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
(function () {
|
||||
|
||||
var state = new Phaser.State();
|
||||
|
||||
state.preload = function() {
|
||||
|
||||
console.log('state preload called');
|
||||
|
||||
// When an instance of Phaser.State is added to Phaser.Game it becomes bound to that game
|
||||
// which opens up lots of handy short-cuts to helpers and libs, such as this.math, this.load, this.cache, etc
|
||||
this.load.image('cockpit', 'assets/pics/cockpit.png');
|
||||
this.load.image('rememberMe', 'assets/pics/remember-me.jpg');
|
||||
this.load.image('overdose', 'assets/pics/lance-overdose-loader_eye.png');
|
||||
this.load.text('copyright', 'assets/warning - copyright.txt');
|
||||
|
||||
}
|
||||
|
||||
state.create = function() {
|
||||
|
||||
console.log('state create called');
|
||||
|
||||
// Let's try adding an image to the DOM
|
||||
document.body.appendChild(this.cache.getImage('cockpit'));
|
||||
|
||||
// And some text
|
||||
var para = document.createElement('pre');
|
||||
para.innerHTML = this.cache.getText('copyright');
|
||||
document.body.appendChild(para);
|
||||
|
||||
}
|
||||
|
||||
var megaBlasterGame = new Phaser.Game();
|
||||
|
||||
// In this approach we're using a Phaser.State object and switching to it
|
||||
// This gives us the advantage that from within state functions you can access 'this' and most the properties of Phaser.Game
|
||||
megaBlasterGame.switchState(state);
|
||||
|
||||
})();
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -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>
|
||||
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
// All JS files in build order.
|
||||
// Much easier for debugging
|
||||
?>
|
||||
<script src="../src/Phaser.js"></script>
|
||||
|
||||
<script src="../src/pixi/Pixi.js"></script>
|
||||
<script src="../src/pixi/InteractionManager.js"></script>
|
||||
<script src="../src/pixi/core/Circle.js"></script>
|
||||
<script src="../src/pixi/core/Ellipse.js"></script>
|
||||
<script src="../src/pixi/core/Matrix.js"></script>
|
||||
<script src="../src/pixi/core/Point.js"></script>
|
||||
<script src="../src/pixi/core/Polygon.js"></script>
|
||||
<script src="../src/pixi/core/Rectangle.js"></script>
|
||||
<script src="../src/pixi/display/DisplayObject.js"></script>
|
||||
<script src="../src/pixi/display/DisplayObjectContainer.js"></script>
|
||||
<script src="../src/pixi/display/Sprite.js"></script>
|
||||
<script src="../src/pixi/display/MovieClip.js"></script>
|
||||
<script src="../src/pixi/display/Stage.js"></script>
|
||||
<script src="../src/pixi/extras/CustomRenderable.js"></script>
|
||||
<script src="../src/pixi/extras/Strip.js"></script>
|
||||
<script src="../src/pixi/extras/Rope.js"></script>
|
||||
<script src="../src/pixi/extras/Spine.js"></script>
|
||||
<script src="../src/pixi/extras/TilingSprite.js"></script>
|
||||
<script src="../src/pixi/filters/FilterBlock.js"></script>
|
||||
<script src="../src/pixi/filters/MaskFilter.js"></script>
|
||||
<script src="../src/pixi/primitives/Graphics.js"></script>
|
||||
<script src="../src/pixi/renderers/canvas/CanvasGraphics.js"></script>
|
||||
<script src="../src/pixi/renderers/canvas/CanvasRenderer.js"></script>
|
||||
<script src="../src/pixi/renderers/webgl/WebGLBatch.js"></script>
|
||||
<script src="../src/pixi/renderers/webgl/WebGLGraphics.js"></script>
|
||||
<script src="../src/pixi/renderers/webgl/WebGLRenderer.js"></script>
|
||||
<script src="../src/pixi/renderers/webgl/WebGLRenderGroup.js"></script>
|
||||
<script src="../src/pixi/renderers/webgl/WebGLShaders.js"></script>
|
||||
<script src="../src/pixi/text/BitmapText.js"></script>
|
||||
<script src="../src/pixi/text/Text.js"></script>
|
||||
<script src="../src/pixi/textures/BaseTexture.js"></script>
|
||||
<script src="../src/pixi/textures/Texture.js"></script>
|
||||
<script src="../src/pixi/textures/RenderTexture.js"></script>
|
||||
<script src="../src/pixi/utils/Detector.js"></script>
|
||||
<script src="../src/pixi/utils/EventTarget.js"></script>
|
||||
<script src="../src/pixi/utils/Polyk.js"></script>
|
||||
<script src="../src/pixi/utils/Utils.js"></script>
|
||||
|
||||
<script src="../src/core/State.js"></script>
|
||||
<script src="../src/system/RequestAnimationFrame.js"></script>
|
||||
<script src="../src/system/Device.js"></script>
|
||||
<script src="../src/core/SignalBinding.js"></script>
|
||||
<script src="../src/core/Signal.js"></script>
|
||||
<script src="../src/core/PluginManager.js"></script>
|
||||
<script src="../src/core/Plugin.js"></script>
|
||||
<script src="../src/math/RandomDataGenerator.js"></script>
|
||||
<script src="../src/math/Math.js"></script>
|
||||
<script src="../src/geom/Point.js"></script>
|
||||
<script src="../src/geom/Circle.js"></script>
|
||||
<script src="../src/net/Net.js"></script>
|
||||
<script src="../src/tween/TweenManager.js"></script>
|
||||
<script src="../src/tween/Tween.js"></script>
|
||||
<script src="../src/tween/Easing.js"></script>
|
||||
<script src="../src/time/Time.js"></script>
|
||||
<script src="../src/animation/Animation.js"></script>
|
||||
<script src="../src/animation/Frame.js"></script>
|
||||
<script src="../src/animation/FrameData.js"></script>
|
||||
<script src="../src/animation/Parser.js"></script>
|
||||
<script src="../src/loader/Cache.js"></script>
|
||||
<script src="../src/loader/Loader.js"></script>
|
||||
<script src="../src/Game.js"></script>
|
||||
Reference in New Issue
Block a user