Tidied up the Loader so it now starts automatically, added required Signals and removed the old-style callbacks.

This commit is contained in:
Richard Davey
2013-08-08 04:35:13 +01:00
parent 04dcb29c88
commit 5768336150
250 changed files with 1461 additions and 1452 deletions
+26 -18
View File
@@ -52,18 +52,18 @@ module Phaser {
* @param parent {string} ID of its parent DOM element.
* @param width {number} The width of your game in game pixels.
* @param height {number} The height of your game in game pixels.
* @param initCallback {function} Init callback invoked when init default screen.
* @param preloadCallback {function} Preload callback invoked when init default screen.
* @param createCallback {function} Create callback invoked when create default screen.
* @param updateCallback {function} Update callback invoked when update default screen.
* @param renderCallback {function} Render callback invoked when render default screen.
* @param destroyCallback {function} Destroy callback invoked when state is destroyed.
*/
constructor(callbackContext, parent?: string = '', width?: number = 800, height?: number = 600, initCallback = null, createCallback = null, updateCallback = null, renderCallback = null, destroyCallback = null) {
constructor(callbackContext, parent?: string = '', width?: number = 800, height?: number = 600, preloadCallback = null, createCallback = null, updateCallback = null, renderCallback = null, destroyCallback = null) {
this.id = Phaser.GAMES.push(this) - 1;
this.callbackContext = callbackContext;
this.onInitCallback = initCallback;
this.onPreloadCallback = preloadCallback;
this.onCreateCallback = createCallback;
this.onUpdateCallback = updateCallback;
this.onRenderCallback = renderCallback;
@@ -92,7 +92,7 @@ module Phaser {
* Milliseconds of time per step of the game loop.
* @type {number}
*/
private _step: number = 0;
//private _step: number = 0;
/**
* Whether load complete loading or not.
@@ -133,7 +133,7 @@ module Phaser {
* This will be called when init states. (loading assets...)
* @type {function}
*/
public onInitCallback = null;
public onPreloadCallback = null;
/**
* This will be called when create states. (setup states...)
@@ -314,7 +314,7 @@ module Phaser {
this.world = new World(this, width, height);
this.add = new GameObjectFactory(this);
this.cache = new Cache(this);
this.load = new Loader(this, this.loadComplete);
this.load = new Loader(this);
this.time = new TimeManager(this);
this.tweens = new TweenManager(this);
this.input = new InputManager(this);
@@ -323,6 +323,8 @@ module Phaser {
this.physics = new Physics.Manager(this);
this.plugins = new PluginManager(this, this);
this.load.onLoadComplete.addOnce(this.loadComplete, this);
this.setRenderer(Phaser.Types.RENDERER_CANVAS);
this.world.boot();
@@ -337,7 +339,7 @@ module Phaser {
DebugUtils.context = this.stage.context;
// Display the default game screen?
if (this.onInitCallback == null && this.onCreateCallback == null && this.onUpdateCallback == null && this.onRenderCallback == null && this._pendingState == null)
if (this.onPreloadCallback == null && this.onCreateCallback == null && this.onUpdateCallback == null && this.onRenderCallback == null && this._pendingState == null)
{
this._raf = new RequestAnimationFrame(this, this.bootLoop);
}
@@ -382,10 +384,11 @@ module Phaser {
}
/**
* Called when the load has finished after init was run.
* Called when the load has finished after preload was run.
*/
private loadComplete() {
this._loadComplete = true;
this.onCreateCallback.call(this.callbackContext);
}
/**
@@ -475,13 +478,13 @@ module Phaser {
*/
private startState() {
if (this.onInitCallback !== null)
if (this.onPreloadCallback !== null)
{
this.load.reset();
this.onInitCallback.call(this.callbackContext);
this.onPreloadCallback.call(this.callbackContext);
// Is the load empty?
// Is the loader empty?
if (this.load.queueSize == 0)
{
if (this.onCreateCallback !== null)
@@ -491,6 +494,11 @@ module Phaser {
this._loadComplete = true;
}
else
{
// Start the loader going as we have something in the queue
this.load.start();
}
}
else
{
@@ -507,15 +515,15 @@ module Phaser {
/**
* Set the most common state callbacks (init, create, update, render).
* @param initCallback {function} Init callback invoked when init state.
* @param preloadCallback {function} Init callback invoked when init state.
* @param createCallback {function} Create callback invoked when create state.
* @param updateCallback {function} Update callback invoked when update state.
* @param renderCallback {function} Render callback invoked when render state.
* @param destroyCallback {function} Destroy callback invoked when state is destroyed.
*/
public setCallbacks(initCallback = null, createCallback = null, updateCallback = null, renderCallback = null, destroyCallback = null) {
public setCallbacks(preloadCallback = null, createCallback = null, updateCallback = null, renderCallback = null, destroyCallback = null) {
this.onInitCallback = initCallback;
this.onPreloadCallback = preloadCallback;
this.onCreateCallback = createCallback;
this.onUpdateCallback = updateCallback;
this.onRenderCallback = renderCallback;
@@ -556,7 +564,7 @@ module Phaser {
{
this.callbackContext = this.state;
this.onInitCallback = null;
this.onPreloadCallback = null;
this.onLoadRenderCallback = null;
this.onLoadUpdateCallback = null;
this.onCreateCallback = null;
@@ -567,9 +575,9 @@ module Phaser {
this.onDestroyCallback = null;
// Bingo, let's set them up
if (this.state['init'])
if (this.state['preload'])
{
this.onInitCallback = this.state['init'];
this.onPreloadCallback = this.state['preload'];
}
if (this.state['loadRender'])
@@ -639,7 +647,7 @@ module Phaser {
public destroy() {
this.callbackContext = null;
this.onInitCallback = null;
this.onPreloadCallback = null;
this.onLoadRenderCallback = null;
this.onLoadUpdateCallback = null;
this.onCreateCallback = null;
+18 -25
View File
@@ -28,7 +28,7 @@ module Phaser {
*/
constructor(game: Game, parent: string, width: number, height: number) {
this._game = game;
this.game = game;
this.canvas = <HTMLCanvasElement> document.createElement('canvas');
this.canvas.width = width;
@@ -56,7 +56,7 @@ module Phaser {
this.css3 = new Phaser.Display.CSS3Filters(this.canvas);
this.scaleMode = StageScaleMode.NO_SCALE;
this.scale = new StageScaleMode(this._game, width, height);
this.scale = new StageScaleMode(this.game, width, height);
this.getOffset(this.canvas);
this.bounds = new Rectangle(this.offset.x, this.offset.y, width, height);
@@ -72,9 +72,9 @@ module Phaser {
}
/**
* Local private reference to game.
* Local reference to Game.
*/
private _game: Game;
public game: Game;
/**
* Background color of the stage (defaults to black). Set via the public backgroundColor property.
@@ -175,21 +175,14 @@ module Phaser {
*/
public disableVisibilityChange: bool = false;
/**
* An optional 'fix' for the horrendous Android stock browser bug
* https://code.google.com/p/android/issues/detail?id=39247
* @type {boolean}
*/
public patchAndroidClearRectBug: bool = false;
/**
* Stage boot
*/
public boot() {
this.bootScreen = new BootScreen(this._game);
this.pauseScreen = new PauseScreen(this._game, this.width, this.height);
this.orientationScreen = new OrientationScreen(this._game);
this.bootScreen = new BootScreen(this.game);
this.pauseScreen = new PauseScreen(this.game, this.width, this.height);
this.orientationScreen = new OrientationScreen(this.game);
this.scale.setScreenSize(true);
@@ -205,9 +198,9 @@ module Phaser {
this.context.setTransform(1, 0, 0, 1, 0, 0);
if (this.clear || (this._game.paused && this.disablePauseScreen == false))
if (this.clear || (this.game.paused && this.disablePauseScreen == false))
{
if (this.patchAndroidClearRectBug)
if (this.game.device.patchAndroidClearRectBug)
{
this.context.fillStyle = 'rgb(0,0,0)';
this.context.fillRect(0, 0, this.width, this.height);
@@ -218,20 +211,20 @@ module Phaser {
}
}
if (this._game.paused && this.scale.incorrectOrientation)
if (this.game.paused && this.scale.incorrectOrientation)
{
this.orientationScreen.update();
this.orientationScreen.render();
return;
}
if (this._game.isRunning == false && this.disableBootScreen == false)
if (this.game.isRunning == false && this.disableBootScreen == false)
{
this.bootScreen.update();
this.bootScreen.render();
}
if (this._game.paused && this.disablePauseScreen == false)
if (this.game.paused && this.disablePauseScreen == false)
{
this.pauseScreen.update();
this.pauseScreen.render();
@@ -251,14 +244,14 @@ module Phaser {
if (event.type == 'pagehide' || event.type == 'blur' || document['hidden'] == true || document['webkitHidden'] == true)
{
if (this._game.paused == false)
if (this.game.paused == false)
{
this.pauseGame();
}
}
else
{
if (this._game.paused == true)
if (this.game.paused == true)
{
this.resumeGame();
}
@@ -277,7 +270,7 @@ module Phaser {
if ((this.scale.isLandscape && forcePortrait) || (this.scale.isPortrait && forceLandscape))
{
// They are in the wrong orientation right now
this._game.paused = true;
this.game.paused = true;
this.scale.incorrectOrientation = true;
}
else
@@ -304,7 +297,7 @@ module Phaser {
this.saveCanvasValues();
this._game.paused = true;
this.game.paused = true;
}
@@ -317,7 +310,7 @@ module Phaser {
this.restoreCanvasValues();
this._game.paused = false;
this.game.paused = false;
}
@@ -383,7 +376,7 @@ module Phaser {
this.context.lineWidth = this.lineWidth;
this.context.fillStyle = this.fillStyle;
if (this.patchAndroidClearRectBug)
if (this.game.device.patchAndroidClearRectBug)
{
this.context.fillStyle = 'rgb(0,0,0)';
this.context.fillRect(0, 0, this.width, this.height);
+6 -6
View File
@@ -27,18 +27,18 @@ module Phaser {
*/
constructor(game: Game, width: number, height: number) {
this._game = game;
this.game = game;
this.cameras = new CameraManager(this._game, 0, 0, width, height);
this.cameras = new CameraManager(this.game, 0, 0, width, height);
this.bounds = new Rectangle(0, 0, width, height);
}
/**
* Local private reference to game.
* Local reference to Game.
*/
private _game: Game;
public game: Game;
/**
* Camera manager of this world.
@@ -79,7 +79,7 @@ module Phaser {
*/
public boot() {
this.group = new Group(this._game, 0);
this.group = new Group(this.game, 0);
}
@@ -127,7 +127,7 @@ module Phaser {
if (updateCameraBounds == true)
{
this._game.camera.setBounds(0, 0, width, height);
this.game.camera.setBounds(0, 0, width, height);
}
// dispatch world resize event
+11 -11
View File
@@ -23,7 +23,7 @@ module Phaser {
*/
constructor(game: Game, parent: Sprite, frameData: FrameData, name: string, frames, delay: number, looped: bool) {
this._game = game;
this.game = game;
this._parent = parent;
this._frames = frames;
this._frameData = frameData;
@@ -41,9 +41,9 @@ module Phaser {
}
/**
* Local private reference to game.
* Local reference to Game.
*/
private _game: Game;
public game: Game;
/**
* Local private reference to its owner sprite.
@@ -167,8 +167,8 @@ module Phaser {
this.isPlaying = true;
this.isFinished = false;
this._timeLastFrame = this._game.time.now;
this._timeNextFrame = this._game.time.now + this.delay;
this._timeLastFrame = this.game.time.now;
this._timeNextFrame = this.game.time.now + this.delay;
this._frameIndex = 0;
@@ -188,8 +188,8 @@ module Phaser {
this.isPlaying = true;
this.isFinished = false;
this._timeLastFrame = this._game.time.now;
this._timeNextFrame = this._game.time.now + this.delay;
this._timeLastFrame = this.game.time.now;
this._timeNextFrame = this.game.time.now + this.delay;
this._frameIndex = 0;
this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]);
@@ -211,7 +211,7 @@ module Phaser {
*/
public update(): bool {
if (this.isPlaying == true && this._game.time.now >= this._timeNextFrame)
if (this.isPlaying == true && this.game.time.now >= this._timeNextFrame)
{
this._frameIndex++;
@@ -233,8 +233,8 @@ module Phaser {
this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]);
}
this._timeLastFrame = this._game.time.now;
this._timeNextFrame = this._game.time.now + this.delay;
this._timeLastFrame = this.game.time.now;
this._timeNextFrame = this.game.time.now + this.delay;
return true;
}
@@ -248,7 +248,7 @@ module Phaser {
*/
public destroy() {
this._game = null;
this.game = null;
this._parent = null;
this._frames = null;
this._frameData = null;
+5 -5
View File
@@ -23,7 +23,7 @@ module Phaser {
*/
constructor(game: Game, x: number, y: number, width: number, height: number) {
this._game = game;
this.game = game;
this._cameras = [];
this._cameraLength = 0;
@@ -35,9 +35,9 @@ module Phaser {
}
/**
* Local private reference to Game.
* Local reference to Game.
*/
private _game: Game;
public game: Game;
/**
* Local container for storing cameras.
@@ -113,7 +113,7 @@ module Phaser {
*/
public addCamera(x: number, y: number, width: number, height: number): Camera {
var newCam: Camera = new Camera(this._game, this._cameraLength, x, y, width, height);
var newCam: Camera = new Camera(this.game, this._cameraLength, x, y, width, height);
this._cameraLength = this._cameras.push(newCam);
@@ -230,7 +230,7 @@ module Phaser {
this._cameras.length = 0;
this.current = this.addCamera(0, 0, this._game.stage.width, this._game.stage.height);
this.current = this.addCamera(0, 0, this.game.stage.width, this.game.stage.height);
}
+17 -17
View File
@@ -24,15 +24,15 @@ module Phaser {
*/
constructor(game: Phaser.Game) {
this._game = game;
this._world = this._game.world;
this.game = game;
this._world = this.game.world;
}
/**
* Local private reference to Game
* Local reference to Game
*/
private _game: Phaser.Game;
public game: Phaser.Game;
/**
* Local private reference to World
@@ -60,7 +60,7 @@ module Phaser {
* @returns {GeomSprite} The newly created geom sprite object.
*/
//public geomSprite(x: number, y: number): GeomSprite {
// return <GeomSprite> this._world.group.add(new GeomSprite(this._game, x, y));
// return <GeomSprite> this._world.group.add(new GeomSprite(this.game, x, y));
//}
/**
@@ -77,7 +77,7 @@ module Phaser {
* @returns {Button} The newly created button object.
*/
public button(x?: number = 0, y?: number = 0, key?: string = null, callback? = null, callbackContext? = null, overFrame? = null, outFrame? = null, downFrame? = null): UI.Button {
return <UI.Button> this._world.group.add(new UI.Button(this._game, x, y, key, callback, callbackContext, overFrame, outFrame, downFrame));
return <UI.Button> this._world.group.add(new UI.Button(this.game, x, y, key, callback, callbackContext, overFrame, outFrame, downFrame));
}
/**
@@ -90,11 +90,11 @@ module Phaser {
* @returns {Sprite} The newly created sprite object.
*/
public sprite(x: number, y: number, key?: string = '', frame? = null): Sprite {
return <Sprite> this._world.group.add(new Sprite(this._game, x, y, key, frame));
return <Sprite> this._world.group.add(new Sprite(this.game, x, y, key, frame));
}
public audio(key: string, volume?: number = 1, loop?: bool = false) {
return <Sound> this._game.sound.add(key, volume, loop);
return <Sound> this.game.sound.add(key, volume, loop);
}
/**
@@ -109,7 +109,7 @@ module Phaser {
* @returns {Sprite} The newly created sprite object.
*/
//public physicsSprite(x: number, y: number, key?: string = '', frame? = null, bodyType?: number = Phaser.Types.BODY_DYNAMIC, shapeType?:number = 0): Sprite {
// return <Sprite> this._world.group.add(new Sprite(this._game, x, y, key, frame, bodyType, shapeType));
// return <Sprite> this._world.group.add(new Sprite(this.game, x, y, key, frame, bodyType, shapeType));
//}
/**
@@ -120,7 +120,7 @@ module Phaser {
* @returns {DynamicTexture} The newly created dynamic texture object.
*/
public dynamicTexture(width: number, height: number): DynamicTexture {
return new DynamicTexture(this._game, width, height);
return new DynamicTexture(this.game, width, height);
}
/**
@@ -130,7 +130,7 @@ module Phaser {
* @returns {Group} The newly created group.
*/
public group(maxSize?: number = 0): Group {
return <Group> this._world.group.add(new Group(this._game, maxSize));
return <Group> this._world.group.add(new Group(this.game, maxSize));
}
/**
@@ -139,7 +139,7 @@ module Phaser {
* @return {Particle} The newly created particle object.
*/
public particle(): ArcadeParticle {
return new ArcadeParticle(this._game);
return new ArcadeParticle(this.game);
}
/**
@@ -151,7 +151,7 @@ module Phaser {
* @return {Emitter} The newly created emitter object.
*/
public emitter(x?: number = 0, y?: number = 0, size?: number = 0): ArcadeEmitter {
return <ArcadeEmitter> this._world.group.add(new ArcadeEmitter(this._game, x, y, size));
return <ArcadeEmitter> this._world.group.add(new ArcadeEmitter(this.game, x, y, size));
}
/**
@@ -165,7 +165,7 @@ module Phaser {
* @returns {ScrollZone} The newly created scroll zone object.
*/
public scrollZone(key: string, x?: number = 0, y?: number = 0, width?: number = 0, height?: number = 0): ScrollZone {
return <ScrollZone> this._world.group.add(new ScrollZone(this._game, key, x, y, width, height));
return <ScrollZone> this._world.group.add(new ScrollZone(this.game, key, x, y, width, height));
}
/**
@@ -180,7 +180,7 @@ module Phaser {
* @return {Tilemap} The newly created tilemap object.
*/
public tilemap(key: string, mapData: string, format: number, resizeWorld: bool = true, tileWidth?: number = 0, tileHeight?: number = 0): Tilemap {
return <Tilemap> this._world.group.add(new Tilemap(this._game, key, mapData, format, resizeWorld, tileWidth, tileHeight));
return <Tilemap> this._world.group.add(new Tilemap(this.game, key, mapData, format, resizeWorld, tileWidth, tileHeight));
}
/**
@@ -191,7 +191,7 @@ module Phaser {
* @return {Phaser.Tween} The newly created tween object.
*/
public tween(obj, localReference?:bool = false): Tween {
return this._game.tweens.create(obj, localReference);
return this.game.tweens.create(obj, localReference);
}
/**
@@ -279,7 +279,7 @@ module Phaser {
* @return {Phaser.Tween} The Tween object
*/
public existingTween(tween: Tween): Tween {
return this._game.tweens.add(tween);
return this.game.tweens.add(tween);
}
}
+13 -13
View File
@@ -19,17 +19,17 @@ module Phaser {
*/
constructor(game: Game) {
this._game = game;
this.game = game;
}
/**
* Local private reference to game.
* Local reference to Game.
* @property _game
* @type {Game}
* @private
**/
private _game: Game;
public game: Game;
private _p1: Pointer;
private _p2: Pointer;
@@ -45,16 +45,16 @@ module Phaser {
public start() {
// Local references to the Phaser.Input.pointer objects
this._p1 = this._game.input.pointer1;
this._p2 = this._game.input.pointer2;
this._p3 = this._game.input.pointer3;
this._p4 = this._game.input.pointer4;
this._p5 = this._game.input.pointer5;
this._p6 = this._game.input.pointer6;
this._p7 = this._game.input.pointer7;
this._p8 = this._game.input.pointer8;
this._p9 = this._game.input.pointer9;
this._p10 = this._game.input.pointer10;
this._p1 = this.game.input.pointer1;
this._p2 = this.game.input.pointer2;
this._p3 = this.game.input.pointer3;
this._p4 = this.game.input.pointer4;
this._p5 = this.game.input.pointer5;
this._p6 = this.game.input.pointer6;
this._p7 = this.game.input.pointer7;
this._p8 = this.game.input.pointer8;
this._p9 = this.game.input.pointer9;
this._p10 = this.game.input.pointer10;
}
+23
View File
@@ -60,6 +60,15 @@ module Phaser {
*/
public game: Game;
/**
* How often should the input pointers be checked for updates?
* A value of 0 means every single frame (60fps), a value of 1 means every other frame (30fps) and so on.
* @type {number}
*/
public pollRate: number = 0;
private _pollCounter: number = 0;
/**
* A 1x1 sized canvas used for pixel-perfect checks
* @type {HTMLCanvasElement}
@@ -495,12 +504,22 @@ module Phaser {
}
public get pollLocked(): bool {
return (this.pollRate > 0 && this._pollCounter < this.pollRate);
}
/**
* Updates the Input Manager. Called by the core Game loop.
* @method update
**/
public update() {
if (this.pollRate > 0 && this._pollCounter < this.pollRate)
{
this._pollCounter++;
return;
}
this.speed.x = this.position.x - this._oldPosition.x;
this.speed.y = this.position.y - this._oldPosition.y;
@@ -519,6 +538,8 @@ module Phaser {
if (this.pointer9) { this.pointer9.update(); }
if (this.pointer10) { this.pointer10.update(); }
this._pollCounter = 0;
}
/**
@@ -568,6 +589,8 @@ module Phaser {
this.totalTrackedObjects = 0;
}
this._pollCounter = 0;
}
public resetSpeed(x: number, y: number) {
+6 -1
View File
@@ -38,7 +38,7 @@ module Phaser {
private _highestInputPriorityID: number;
/**
* Local private reference to game.
* Local reference to Game.
* @property game
* @type {Phaser.Game}
* @private
@@ -419,6 +419,11 @@ module Phaser {
*/
public move(event): Pointer {
if (this.game.input.pollLocked)
{
return;
}
if (event.button)
{
this.button = event.button;
+7 -7
View File
@@ -16,7 +16,7 @@ module Phaser {
*/
constructor(game: Game) {
this._game = game;
this.game = game;
this._canvases = {};
this._images = {};
@@ -26,9 +26,9 @@ module Phaser {
}
/**
* Local private reference to game.
* Local reference to Game.
*/
private _game: Game;
public game: Game;
/**
* Canvas key-value container.
@@ -78,7 +78,7 @@ module Phaser {
public addSpriteSheet(key: string, url: string, data, frameWidth: number, frameHeight: number, frameMax: number) {
this._images[key] = { url: url, data: data, spriteSheet: true, frameWidth: frameWidth, frameHeight: frameHeight };
this._images[key].frameData = AnimationLoader.parseSpriteSheet(this._game, key, frameWidth, frameHeight, frameMax);
this._images[key].frameData = AnimationLoader.parseSpriteSheet(this.game, key, frameWidth, frameHeight, frameMax);
}
@@ -95,11 +95,11 @@ module Phaser {
if (format == Phaser.Loader.TEXTURE_ATLAS_JSON_ARRAY)
{
this._images[key].frameData = AnimationLoader.parseJSONData(this._game, atlasData);
this._images[key].frameData = AnimationLoader.parseJSONData(this.game, atlasData);
}
else if (format == Phaser.Loader.TEXTURE_ATLAS_XML_STARLING)
{
this._images[key].frameData = AnimationLoader.parseXMLData(this._game, atlasData, format);
this._images[key].frameData = AnimationLoader.parseXMLData(this.game, atlasData, format);
}
}
@@ -124,7 +124,7 @@ module Phaser {
*/
public addSound(key: string, url: string, data, webAudio: bool = true, audioTag: bool = false) {
var locked: bool = this._game.sound.touchLocked;
var locked: bool = this.game.sound.touchLocked;
var decoded: bool = false;
if (audioTag) {
+57 -60
View File
@@ -15,26 +15,31 @@ module Phaser {
* Loader constructor
*
* @param game {Phaser.Game} Current game instance.
* @param callback {function} This will be called when assets completely loaded.
*/
constructor(game: Game, callback) {
constructor(game: Game) {
this.game = game;
this._game = game;
this._gameCreateComplete = callback;
this._keys = [];
this._fileList = {};
this._xhr = new XMLHttpRequest();
this._queueSize = 0;
this.isLoading = false;
this.onFileComplete = new Phaser.Signal;
this.onFileError = new Phaser.Signal;
this.onLoadStart = new Phaser.Signal;
this.onLoadComplete = new Phaser.Signal;
}
/**
* Local private reference to game.
* Local reference to Game.
*/
private _game: Game;
public game: Game;
/**
* Array stors assets keys. So you can get that asset by its unique key.
* Array stores assets keys. So you can get that asset by its unique key.
*/
private _keys: string[];
@@ -43,13 +48,6 @@ module Phaser {
*/
private _fileList;
/**
* Game initialial assets loading callback.
*/
private _gameCreateComplete;
private _onComplete;
private _onFileLoad;
/**
* Indicates assets loading progress. (from 0 to 100)
* @type {number}
@@ -64,6 +62,12 @@ module Phaser {
*/
private _queueSize: number;
/**
* True if the Loader is in the process of loading a queue.
* @type {boolean}
*/
public isLoading: bool;
/**
* True if game is completely loaded.
* @type {boolean}
@@ -82,6 +86,11 @@ module Phaser {
*/
public crossOrigin: string = '';
public onFileComplete: Phaser.Signal;
public onFileError: Phaser.Signal;
public onLoadStart: Phaser.Signal;
public onLoadComplete: Phaser.Signal;
/**
* TextureAtlas data format constants
*/
@@ -94,6 +103,7 @@ module Phaser {
*/
public reset() {
this._queueSize = 0;
this.isLoading = false;
}
public get queueSize(): number {
@@ -269,22 +279,19 @@ module Phaser {
/**
* Load assets.
* @param onFileLoadCallback {function} Called when each file loaded successfully.
* @param onCompleteCallback {function} Called when all assets completely loaded.
*/
public start(onFileLoadCallback = null, onCompleteCallback = null) {
public start() {
if (this.isLoading)
{
return;
}
this.progress = 0;
this.hasLoaded = false;
this.isLoading = true;
this._onComplete = onCompleteCallback;
if (onCompleteCallback == null)
{
this._onComplete = this._game.onCreateCallback;
}
this._onFileLoad = onFileLoadCallback;
this.onLoadStart.dispatch(this.queueSize);
if (this._keys.length > 0)
{
@@ -295,12 +302,7 @@ module Phaser {
{
this.progress = 100;
this.hasLoaded = true;
this._gameCreateComplete.call(this._game);
if (this._onComplete !== null)
{
this._onComplete.call(this._game.callbackContext);
}
this.onLoadComplete.dispatch();
}
}
@@ -334,7 +336,7 @@ module Phaser {
if (file.url !== null)
{
// WebAudio or Audio Tag?
if (this._game.sound.usingWebAudio)
if (this.game.sound.usingWebAudio)
{
this._xhr.open("GET", file.url, true);
this._xhr.responseType = "arraybuffer";
@@ -342,9 +344,9 @@ module Phaser {
this._xhr.onerror = () => this.fileError(file.key);
this._xhr.send();
}
else if (this._game.sound.usingAudioTag)
else if (this.game.sound.usingAudioTag)
{
if (this._game.sound.touchLocked)
if (this.game.sound.touchLocked)
{
// If audio is locked we can't do this yet, so need to queue this load request somehow. Bum.
file.data = new Audio();
@@ -360,7 +362,7 @@ module Phaser {
file.data.onerror = () => this.fileError(file.key);
file.data.preload = 'auto';
file.data.src = file.url;
file.data.addEventListener('canplaythrough', Phaser.GAMES[this._game.id].load.fileComplete(file.key), false);
file.data.addEventListener('canplaythrough', Phaser.GAMES[this.game.id].load.fileComplete(file.key), false);
file.data.load();
}
}
@@ -388,10 +390,8 @@ module Phaser {
extension = urls[i].toLowerCase();
extension = extension.substr((Math.max(0, extension.lastIndexOf(".")) || Infinity) + 1);
if (this._game.device.canPlayAudio(extension))
if (this.game.device.canPlayAudio(extension))
{
//console.log('getAudioURL', urls[i]);
//console.log(urls[i]);
return urls[i];
}
@@ -410,6 +410,8 @@ module Phaser {
this._fileList[key].loaded = true;
this._fileList[key].error = true;
this.onFileError.dispatch(key);
throw new Error("Phaser.Loader error loading file: " + key);
this.nextFile(key, false);
@@ -436,17 +438,17 @@ module Phaser {
switch (file.type)
{
case 'image':
this._game.cache.addImage(file.key, file.url, file.data);
this.game.cache.addImage(file.key, file.url, file.data);
break;
case 'spritesheet':
this._game.cache.addSpriteSheet(file.key, file.url, file.data, file.frameWidth, file.frameHeight, file.frameMax);
this.game.cache.addSpriteSheet(file.key, file.url, file.data, file.frameWidth, file.frameHeight, file.frameMax);
break;
case 'textureatlas':
if (file.atlasURL == null)
{
this._game.cache.addTextureAtlas(file.key, file.url, file.data, file.atlasData, file.format);
this.game.cache.addTextureAtlas(file.key, file.url, file.data, file.atlasData, file.format);
}
else
{
@@ -471,37 +473,37 @@ module Phaser {
case 'audio':
if (this._game.sound.usingWebAudio)
if (this.game.sound.usingWebAudio)
{
file.data = this._xhr.response;
this._game.cache.addSound(file.key, file.url, file.data, true, false);
this.game.cache.addSound(file.key, file.url, file.data, true, false);
if (file.autoDecode)
{
this._game.cache.updateSound(key, 'isDecoding', true);
this.game.cache.updateSound(key, 'isDecoding', true);
var that = this;
var key = file.key;
this._game.sound.context.decodeAudioData(file.data, function (buffer) {
this.game.sound.context.decodeAudioData(file.data, function (buffer) {
if (buffer)
{
that._game.cache.decodedSound(key, buffer);
that.game.cache.decodedSound(key, buffer);
}
});
}
}
else
{
file.data.removeEventListener('canplaythrough', Phaser.GAMES[this._game.id].load.fileComplete);
this._game.cache.addSound(file.key, file.url, file.data, false, true);
file.data.removeEventListener('canplaythrough', Phaser.GAMES[this.game.id].load.fileComplete);
this.game.cache.addSound(file.key, file.url, file.data, false, true);
}
break;
case 'text':
file.data = this._xhr.response;
this._game.cache.addText(file.key, file.url, file.data);
this.game.cache.addText(file.key, file.url, file.data);
break;
}
@@ -521,7 +523,7 @@ module Phaser {
var data = JSON.parse(this._xhr.response);
var file = this._fileList[key];
this._game.cache.addTextureAtlas(file.key, file.url, file.data, data, file.format);
this.game.cache.addTextureAtlas(file.key, file.url, file.data, data, file.format);
this.nextFile(key, true);
@@ -573,7 +575,7 @@ module Phaser {
}
var file = this._fileList[key];
this._game.cache.addTextureAtlas(file.key, file.url, file.data, xml, file.format);
this.game.cache.addTextureAtlas(file.key, file.url, file.data, xml, file.format);
this.nextFile(key, true);
@@ -593,10 +595,7 @@ module Phaser {
this.progress = 100;
}
if (this._onFileLoad)
{
this._onFileLoad.call(this._game.callbackContext, this.progress, previousKey, success);
}
this.onFileComplete.dispatch(this.progress, previousKey, success, this._queueSize - this._keys.length, this._queueSize);
if (this._keys.length > 0)
{
@@ -605,13 +604,11 @@ module Phaser {
else
{
this.hasLoaded = true;
this.isLoading = false;
this.removeAll();
this._gameCreateComplete.call(this._game);
if (this._onComplete !== null)
{
this._onComplete.call(this._game.callbackContext);
}
this.onLoadComplete.dispatch();
}
}
+9 -1
View File
@@ -39,7 +39,15 @@ module Phaser.Renderer.Canvas {
return false;
}
camera.texture.context.clearRect(0, 0, camera.width, camera.height);
if (this.game.device.patchAndroidClearRectBug)
{
camera.texture.context.fillStyle = 'rgb(0,0,0)';
camera.texture.context.fillRect(0, 0, camera.width, camera.height);
}
else
{
camera.texture.context.clearRect(0, 0, camera.width, camera.height);
}
// Alpha
if (camera.texture.alpha !== 1 && camera.texture.context.globalAlpha != camera.texture.alpha)
+9
View File
@@ -25,6 +25,15 @@ module Phaser {
}
// Android bug specific :)
/**
* An optional 'fix' for the horrendous Android stock browser bug
* https://code.google.com/p/android/issues/detail?id=39247
* @type {boolean}
*/
public patchAndroidClearRectBug: bool = false;
// Operating System
/**
+7 -7
View File
@@ -17,7 +17,7 @@ module Phaser {
*/
constructor(game: Game, callback) {
this._game = game;
this.game = game;
this.callback = callback;
var vendors = ['ms', 'moz', 'webkit', 'o'];
@@ -33,9 +33,9 @@ module Phaser {
}
/**
* Local private reference to game.
* Local reference to Game.
*/
private _game: Game;
public game: Game;
/**
* The function to be called each frame. Will be called in the context of _game
@@ -148,11 +148,11 @@ module Phaser {
**/
public RAFUpdate(time: number) {
this._game.time.update(time);
this.game.time.update(time);
if (this.callback)
{
this.callback.call(this._game);
this.callback.call(this.game);
}
this._onLoop = (time) => this.RAFUpdate(time);
@@ -167,7 +167,7 @@ module Phaser {
**/
public SetTimeoutUpdate() {
this._game.time.update(Date.now());
this.game.time.update(Date.now());
this._onLoop = () => this.SetTimeoutUpdate();
@@ -175,7 +175,7 @@ module Phaser {
if (this.callback)
{
this.callback.call(this._game);
this.callback.call(this.game);
}
}
+28 -28
View File
@@ -17,7 +17,7 @@ module Phaser {
*/
constructor(game: Game, width: number, height: number) {
this._game = game;
this.game = game;
this.enterLandscape = new Phaser.Signal();
this.enterPortrait = new Phaser.Signal();
@@ -51,9 +51,9 @@ module Phaser {
}
/**
* Local private reference to game.
* Local reference to Game.
*/
private _game: Game;
public game: Game;
/**
* Stage height when start the game.
@@ -208,7 +208,7 @@ module Phaser {
return;
}
var element = this._game.stage.canvas;
var element = this.game.stage.canvas;
if (element['requestFullScreen'])
{
@@ -247,7 +247,7 @@ module Phaser {
*/
public update() {
if (this._game.stage.scaleMode !== StageScaleMode.NO_SCALE && (window.innerWidth !== this.width || window.innerHeight !== this.height))
if (this.game.stage.scaleMode !== StageScaleMode.NO_SCALE && (window.innerWidth !== this.width || window.innerHeight !== this.height))
{
this.refresh();
}
@@ -267,7 +267,7 @@ module Phaser {
if ((this.forceLandscape && window.innerWidth > window.innerHeight) || (this.forcePortrait && window.innerHeight > window.innerWidth))
{
// Back to normal
this._game.paused = false;
this.game.paused = false;
this.incorrectOrientation = false;
this.refresh();
}
@@ -277,7 +277,7 @@ module Phaser {
if ((this.forceLandscape && window.innerWidth < window.innerHeight) || (this.forcePortrait && window.innerHeight < window.innerWidth))
{
// Show orientation screen
this._game.paused = true;
this.game.paused = true;
this.incorrectOrientation = true;
this.refresh();
}
@@ -309,7 +309,7 @@ module Phaser {
this.enterPortrait.dispatch(this.orientation, false, true);
}
if (this._game.stage.scaleMode !== StageScaleMode.NO_SCALE)
if (this.game.stage.scaleMode !== StageScaleMode.NO_SCALE)
{
this.refresh();
}
@@ -339,7 +339,7 @@ module Phaser {
this.enterPortrait.dispatch(this.orientation, false, true);
}
if (this._game.stage.scaleMode !== StageScaleMode.NO_SCALE)
if (this.game.stage.scaleMode !== StageScaleMode.NO_SCALE)
{
this.refresh();
}
@@ -352,13 +352,13 @@ module Phaser {
private refresh() {
// We can't do anything about the status bars in iPads, web apps or desktops
if (this._game.device.iPad == false && this._game.device.webApp == false && this._game.device.desktop == false)
if (this.game.device.iPad == false && this.game.device.webApp == false && this.game.device.desktop == false)
{
document.documentElement.style.minHeight = '2000px';
this._startHeight = window.innerHeight;
if (this._game.device.android && this._game.device.chrome == false)
if (this.game.device.android && this.game.device.chrome == false)
{
window.scrollTo(0, 1);
}
@@ -382,9 +382,9 @@ module Phaser {
*/
public setScreenSize(force: bool = false) {
if (this._game.device.iPad == false && this._game.device.webApp == false && this._game.device.desktop == false)
if (this.game.device.iPad == false && this.game.device.webApp == false && this.game.device.desktop == false)
{
if (this._game.device.android && this._game.device.chrome == false)
if (this.game.device.android && this.game.device.chrome == false)
{
window.scrollTo(0, 1);
}
@@ -405,11 +405,11 @@ module Phaser {
{
this.setMaximum();
}
else if (this._game.stage.scaleMode == StageScaleMode.EXACT_FIT)
else if (this.game.stage.scaleMode == StageScaleMode.EXACT_FIT)
{
this.setExactFit();
}
else if (this._game.stage.scaleMode == StageScaleMode.SHOW_ALL)
else if (this.game.stage.scaleMode == StageScaleMode.SHOW_ALL)
{
this.setShowAll();
}
@@ -449,20 +449,20 @@ module Phaser {
}
}
this._game.stage.canvas.style.width = this.width + 'px';
this._game.stage.canvas.style.height = this.height + 'px';
this.game.stage.canvas.style.width = this.width + 'px';
this.game.stage.canvas.style.height = this.height + 'px';
this._game.input.scale.setTo(this._game.stage.width / this.width, this._game.stage.height / this.height);
this.game.input.scale.setTo(this.game.stage.width / this.width, this.game.stage.height / this.height);
if (this.pageAlignHorizontally)
{
if (this.width < window.innerWidth && this.incorrectOrientation == false)
{
this._game.stage.canvas.style.marginLeft = Math.round((window.innerWidth - this.width) / 2) + 'px';
this.game.stage.canvas.style.marginLeft = Math.round((window.innerWidth - this.width) / 2) + 'px';
}
else
{
this._game.stage.canvas.style.marginLeft = '0px';
this.game.stage.canvas.style.marginLeft = '0px';
}
}
@@ -470,19 +470,19 @@ module Phaser {
{
if (this.height < window.innerHeight && this.incorrectOrientation == false)
{
this._game.stage.canvas.style.marginTop = Math.round((window.innerHeight - this.height) / 2) + 'px';
this.game.stage.canvas.style.marginTop = Math.round((window.innerHeight - this.height) / 2) + 'px';
}
else
{
this._game.stage.canvas.style.marginTop = '0px';
this.game.stage.canvas.style.marginTop = '0px';
}
}
this._game.stage.getOffset(this._game.stage.canvas);
this.game.stage.getOffset(this.game.stage.canvas);
this.aspectRatio = this.width / this.height;
this.scaleFactor.x = this._game.stage.width / this.width;
this.scaleFactor.y = this._game.stage.height / this.height;
this.scaleFactor.x = this.game.stage.width / this.width;
this.scaleFactor.y = this.game.stage.height / this.height;
}
@@ -495,10 +495,10 @@ module Phaser {
private setShowAll() {
var multiplier = Math.min((window.innerHeight / this._game.stage.height), (window.innerWidth / this._game.stage.width));
var multiplier = Math.min((window.innerHeight / this.game.stage.height), (window.innerWidth / this.game.stage.width));
this.width = Math.round(this._game.stage.width * multiplier);
this.height = Math.round(this._game.stage.height * multiplier);
this.width = Math.round(this.game.stage.width * multiplier);
this.height = Math.round(this.game.stage.height * multiplier);
}
+23 -23
View File
@@ -19,7 +19,7 @@ module Phaser {
*/
constructor(game:Game) {
this._game = game;
this.game = game;
this._logo = new Image();
this._logo.src = this._logoData;
@@ -27,9 +27,9 @@ module Phaser {
}
/**
* Local private reference to game.
* Local reference to Game.
*/
private _game: Game;
public game: Game;
/**
* Engine logo.
*/
@@ -76,34 +76,34 @@ module Phaser {
*/
public render() {
var grd = this._game.stage.context.createLinearGradient(0, 0, 0, this._game.stage.height);
var grd = this.game.stage.context.createLinearGradient(0, 0, 0, this.game.stage.height);
grd.addColorStop(0, 'rgb(' + this._color1.r + ', ' + this._color1.g + ', ' + this._color1.b + ')');
grd.addColorStop(0.5, 'rgb(' + this._color2.r + ', ' + this._color2.g + ', ' + this._color2.b + ')');
grd.addColorStop(1, 'rgb(' + this._color1.r + ', ' + this._color1.g + ', ' + this._color1.b + ')');
this._game.stage.context.fillStyle = grd;
this._game.stage.context.fillRect(0, 0, this._game.stage.width, this._game.stage.height);
this.game.stage.context.fillStyle = grd;
this.game.stage.context.fillRect(0, 0, this.game.stage.width, this.game.stage.height);
this._game.stage.context.shadowOffsetX = 0;
this._game.stage.context.shadowOffsetY = 0;
this.game.stage.context.shadowOffsetX = 0;
this.game.stage.context.shadowOffsetY = 0;
if (this._logo)
{
this._game.stage.context.drawImage(this._logo, 32, 32);
this.game.stage.context.drawImage(this._logo, 32, 32);
}
this._game.stage.context.shadowColor = 'rgb(0,0,0)';
this._game.stage.context.shadowOffsetX = 1;
this._game.stage.context.shadowOffsetY = 1;
this._game.stage.context.shadowBlur = 0;
this._game.stage.context.fillStyle = 'rgb(255,255,255)';
this._game.stage.context.font = 'bold 18px Arial';
this._game.stage.context.textBaseline = 'top';
this._game.stage.context.fillText(Phaser.VERSION, 32, 64+32);
this._game.stage.context.fillText('Game Size: ' + this._game.stage.width + ' x ' + this._game.stage.height, 32, 64+64);
this._game.stage.context.fillText('www.photonstorm.com', 32, 64+96);
this._game.stage.context.font = '16px Arial';
this._game.stage.context.fillText('You are seeing this screen because you didn\'t specify any default', 32, 64+160);
this._game.stage.context.fillText('functions in the Game constructor or use Game.switchState()', 32, 64+184);
this.game.stage.context.shadowColor = 'rgb(0,0,0)';
this.game.stage.context.shadowOffsetX = 1;
this.game.stage.context.shadowOffsetY = 1;
this.game.stage.context.shadowBlur = 0;
this.game.stage.context.fillStyle = 'rgb(255,255,255)';
this.game.stage.context.font = 'bold 18px Arial';
this.game.stage.context.textBaseline = 'top';
this.game.stage.context.fillText(Phaser.VERSION, 32, 64+32);
this.game.stage.context.fillText('Game Size: ' + this.game.stage.width + ' x ' + this.game.stage.height, 32, 64+64);
this.game.stage.context.fillText('www.photonstorm.com', 32, 64+96);
this.game.stage.context.font = '16px Arial';
this.game.stage.context.fillText('You are seeing this screen because you didn\'t specify any default', 32, 64+160);
this.game.stage.context.fillText('functions in the Game constructor or use Game.switchState()', 32, 64+184);
}
@@ -112,7 +112,7 @@ module Phaser {
*/
private colorCycle() {
this._fade = this._game.add.tween(this._color2);
this._fade = this.game.add.tween(this._color2);
this._fade.to({ r: Math.random() * 250, g: Math.random() * 250, b: Math.random() * 250 }, 3000, Phaser.Easing.Linear.None);
this._fade.onComplete.add(this.colorCycle, this);
+21 -21
View File
@@ -19,7 +19,7 @@ module Phaser {
*/
constructor(game: Game, width: number, height: number) {
this._game = game;
this.game = game;
this._canvas = <HTMLCanvasElement> document.createElement('canvas');
this._canvas.width = width;
this._canvas.height = height;
@@ -28,9 +28,9 @@ module Phaser {
}
/**
* Local private reference to game.
* Local reference to Game.
*/
private _game: Game;
public game: Game;
/**
* Canvas element used by engine.
@@ -62,7 +62,7 @@ module Phaser {
// Take a grab of the current canvas to our temporary one
this._context.clearRect(0, 0, this._canvas.width, this._canvas.height);
this._context.drawImage(this._game.stage.canvas, 0, 0);
this._context.drawImage(this.game.stage.canvas, 0, 0);
this._color = { r: 255, g: 255, b: 255 };
this.fadeOut();
@@ -73,7 +73,7 @@ module Phaser {
*/
public onResume() {
this._fade.stop();
this._game.tweens.remove(this._fade);
this.game.tweens.remove(this._fade);
}
/**
@@ -90,25 +90,25 @@ module Phaser {
*/
public render() {
this._game.stage.context.drawImage(this._canvas, 0, 0);
this.game.stage.context.drawImage(this._canvas, 0, 0);
this._game.stage.context.fillStyle = 'rgba(0, 0, 0, 0.4)';
this._game.stage.context.fillRect(0, 0, this._game.stage.width, this._game.stage.height);
this.game.stage.context.fillStyle = 'rgba(0, 0, 0, 0.4)';
this.game.stage.context.fillRect(0, 0, this.game.stage.width, this.game.stage.height);
// Draw a 'play' arrow
var arrowWidth = Math.round(this._game.stage.width / 2);
var arrowHeight = Math.round(this._game.stage.height / 2);
var arrowWidth = Math.round(this.game.stage.width / 2);
var arrowHeight = Math.round(this.game.stage.height / 2);
var sx = this._game.stage.centerX - arrowWidth / 2;
var sy = this._game.stage.centerY - arrowHeight / 2;
var sx = this.game.stage.centerX - arrowWidth / 2;
var sy = this.game.stage.centerY - arrowHeight / 2;
this._game.stage.context.beginPath();
this._game.stage.context.moveTo(sx, sy);
this._game.stage.context.lineTo(sx, sy + arrowHeight);
this._game.stage.context.lineTo(sx + arrowWidth, this._game.stage.centerY);
this._game.stage.context.fillStyle = 'rgba(' + this._color.r + ', ' + this._color.g + ', ' + this._color.b + ', 0.8)';
this._game.stage.context.fill();
this._game.stage.context.closePath();
this.game.stage.context.beginPath();
this.game.stage.context.moveTo(sx, sy);
this.game.stage.context.lineTo(sx, sy + arrowHeight);
this.game.stage.context.lineTo(sx + arrowWidth, this.game.stage.centerY);
this.game.stage.context.fillStyle = 'rgba(' + this._color.r + ', ' + this._color.g + ', ' + this._color.b + ', 0.8)';
this.game.stage.context.fill();
this.game.stage.context.closePath();
}
@@ -117,7 +117,7 @@ module Phaser {
*/
private fadeOut() {
this._fade = this._game.add.tween(this._color);
this._fade = this.game.add.tween(this._color);
this._fade.to({ r: 50, g: 50, b: 50 }, 1000, Phaser.Easing.Linear.None);
this._fade.onComplete.add(this.fadeIn, this);
@@ -130,7 +130,7 @@ module Phaser {
*/
private fadeIn() {
this._fade = this._game.add.tween(this._color);
this._fade = this.game.add.tween(this._color);
this._fade.to({ r: 255, g: 255, b: 255 }, 1000, Phaser.Easing.Linear.None);
this._fade.onComplete.add(this.fadeOut, this);
+3 -3
View File
@@ -21,7 +21,7 @@ module Phaser {
*/
constructor(game: Game, tilemap: Tilemap, index: number, width: number, height: number) {
this._game = game;
this.game = game;
this.tilemap = tilemap;
this.index = index;
@@ -32,9 +32,9 @@ module Phaser {
}
/**
* Local private reference to game.
* Local reference to Game.
*/
private _game: Game;
public game: Game;
/**
* You can give this Tile a friendly name to help with debugging. Never used internally.
+1 -1
View File
@@ -64,7 +64,7 @@ module Phaser {
private _tempBlockResults;
/**
* Local private reference to game.
* Local reference to Game.
*/
public game: Game;
+10 -10
View File
@@ -32,9 +32,9 @@ module Phaser {
this._object = object;
this._game = game;
this._manager = this._game.tweens;
this._interpolationFunction = this._game.math.linearInterpolation;
this.game = game;
this._manager = this.game.tweens;
this._interpolationFunction = this.game.math.linearInterpolation;
this._easingFunction = Phaser.Easing.Linear.None;
this._chainedTweens = [];
@@ -45,9 +45,9 @@ module Phaser {
}
/**
* Local private reference to game.
* Local reference to Game.
*/
private _game: Phaser.Game;
public game: Phaser.Game;
/**
* Manager of this tween.
@@ -194,7 +194,7 @@ module Phaser {
*/
public start(looped: bool = false): Tween {
if (this._game === null || this._object === null)
if (this.game === null || this._object === null)
{
return;
}
@@ -206,7 +206,7 @@ module Phaser {
this.onStart.dispatch(this._object);
}
this._startTime = this._game.time.now + this._delayTime;
this._startTime = this.game.time.now + this._delayTime;
this.isRunning = true;
for (var property in this._valuesEnd)
@@ -302,8 +302,8 @@ module Phaser {
public set parent(value:Phaser.Game) {
this._game = value;
this._manager = this._game.tweens;
this.game = value;
this._manager = this.game.tweens;
}
@@ -351,7 +351,7 @@ module Phaser {
*/
public update(time) {
if (this._game.paused == true)
if (this.game.paused == true)
{
if (this._pausedTime == 0)
{
+7 -7
View File
@@ -21,15 +21,15 @@ module Phaser {
*/
constructor(game: Phaser.Game) {
this._game = game;
this.game = game;
this._tweens = [];
}
/**
* Local private reference to Game
* Local reference to Game
*/
private _game: Phaser.Game;
public game: Phaser.Game;
/**
* Local private array which is the container of all tween objects.
@@ -66,12 +66,12 @@ module Phaser {
if (localReference)
{
object['tween'] = new Phaser.Tween(object, this._game);
object['tween'] = new Phaser.Tween(object, this.game);
return object['tween'];
}
else
{
return new Phaser.Tween(object, this._game);
return new Phaser.Tween(object, this.game);
}
}
@@ -84,7 +84,7 @@ module Phaser {
*/
public add(tween: Phaser.Tween) {
tween.parent = this._game;
tween.parent = this.game;
this._tweens.push(tween);
@@ -125,7 +125,7 @@ module Phaser {
while (i < numTweens)
{
if (this._tweens[i].update(this._game.time.now))
if (this._tweens[i].update(this.game.time.now))
{
i++;
}
+3 -3
View File
@@ -131,7 +131,7 @@ module Phaser {
if (camera == null)
{
camera = this._game.camera;
camera = this.game.camera;
}
var objectScreenPos: Point = objectOrGroup.getScreenXY(null, camera);
@@ -236,7 +236,7 @@ module Phaser {
if (camera == null)
{
camera = this._game.camera;
camera = this.game.camera;
}
point.x = sprite.x - camera.x * sprite.transform.scrollFactor.x;
@@ -256,7 +256,7 @@ module Phaser {
/*
static setBoundsFromWorld(action?: number = GameObject.OUT_OF_BOUNDS_STOP) {
this.setBounds(this._game.world.bounds.x, this._game.world.bounds.y, this._game.world.bounds.width, this._game.world.bounds.height);
this.setBounds(this.game.world.bounds.x, this.game.world.bounds.y, this.game.world.bounds.width, this.game.world.bounds.height);
this.outOfBoundsAction = action;
}
+9 -2
View File
@@ -17,6 +17,12 @@ Try out the [Phaser Test Suite](http://gametest.mobi/phaser/)
"Being negative is not how we make progress" - Larry Page, Google
Known Issues
------------
* Input detection on Sprites/Buttons doesn't work if the CAMERA is rotated or scaled.
Latest Update
-------------
@@ -25,7 +31,7 @@ TODO:
* Inject game into a <div>
* Add ability to create extra <div>s within the game container, layered above/below the canvas
* Rename init to preload and call start automatically
* Poll the Input handlers less frequently (every other frame?)
* Allow camera to directly render to the stage rather than its hidden (maybe does this by default? or have under Mobile Optimisations list)
@@ -158,7 +164,8 @@ V1.0.0
* Fixed interesting Firefox issue when an audio track ended it fired another 'canplaythrough' event, confusing the Loader.
* Added the new PluginManager. Moved all the Camera FX over to plugins. Everything will be a plugin from now on.
* Added Sprite.transform.centerOn(x,y) to quickly center a sprite on a coordinate without messing with the sprite origin and regardless of rotation.
* Added Input.pollRate - this lets you limit how often Pointer events are handled (0 = every frame, 1 = every other frame, etc)
* Renamed the 'init' function to 'preload' and now call load.start automatically.
V0.9.6
+2 -3
View File
@@ -3,15 +3,14 @@
/// <reference path="../../Phaser/sound/Sound.ts" />
//var PhaserGlobal = { disableWebAudio: true };
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render);
function init() {
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
function preload() {
game.load.audio('rabbit', [
'assets/mp3/peter_rabbit.m4a',
'assets/mp3/peter_rabbit.mp3',
'assets/mp3/peter_rabbit.ogg'
]);
game.load.spritesheet('button', 'assets/buttons/button_sprite_sheet.png', 193, 71);
game.load.start();
}
audioSprite:
Phaser.Sound
+3 -3
View File
@@ -6,13 +6,13 @@
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render);
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
function init() {
function preload() {
game.load.audio('rabbit', ['assets/mp3/peter_rabbit.m4a', 'assets/mp3/peter_rabbit.mp3', 'assets/mp3/peter_rabbit.ogg']);
game.load.spritesheet('button', 'assets/buttons/button_sprite_sheet.png', 193, 71);
game.load.start();
}
+2 -3
View File
@@ -3,14 +3,13 @@
/// <reference path="../../Phaser/sound/Sound.ts" />
//var PhaserGlobal = { fakeiOSTouchLock: true, disableWebAudio: true };
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render);
function init() {
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
function preload() {
//game.load.audio('wizball', ['assets/mp3/oedipus_wizball_highscore.ogg', 'assets/mp3/oedipus_wizball_highscore.mp3']);
game.load.audio('boden', [
'assets/mp3/bodenstaendig_2000_in_rock_4bit.mp3'
]);
game.load.spritesheet('button', 'assets/buttons/button_sprite_sheet.png', 193, 71);
game.load.start();
}
button:
Phaser.UI.Button
+3 -3
View File
@@ -6,14 +6,14 @@
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render);
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
function init() {
function preload() {
//game.load.audio('wizball', ['assets/mp3/oedipus_wizball_highscore.ogg', 'assets/mp3/oedipus_wizball_highscore.mp3']);
game.load.audio('boden', ['assets/mp3/bodenstaendig_2000_in_rock_4bit.mp3']);
game.load.spritesheet('button', 'assets/buttons/button_sprite_sheet.png', 193, 71);
game.load.start();
}
+2 -3
View File
@@ -1,11 +1,10 @@
/// <reference path="../../Phaser/Game.ts" />
/// <reference path="../../Phaser/ui/Button.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create);
function init() {
var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
function preload() {
game.load.image('beast', 'assets/pics/shadow_of_the_beast2_other_world.png');
game.load.atlas('button', 'assets/buttons/button_texture_atlas.png', 'assets/buttons/button_texture_atlas.json');
game.load.start();
}
image:
Phaser.Sprite
+3 -3
View File
@@ -3,13 +3,13 @@
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create);
var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
function init() {
function preload() {
game.load.image('beast', 'assets/pics/shadow_of_the_beast2_other_world.png');
game.load.atlas('button', 'assets/buttons/button_texture_atlas.png', 'assets/buttons/button_texture_atlas.json');
game.load.start();
}
+2 -3
View File
@@ -1,11 +1,10 @@
/// <reference path="../../Phaser/Game.ts" />
/// <reference path="../../Phaser/ui/Button.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create);
function init() {
var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
function preload() {
game.load.image('beast', 'assets/pics/shadow_of_the_beast2_karamoon.png');
game.load.spritesheet('button', 'assets/buttons/button_sprite_sheet.png', 193, 71);
game.load.start();
}
image:
Phaser.Sprite
+3 -3
View File
@@ -3,13 +3,13 @@
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create);
var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
function init() {
function preload() {
game.load.image('beast', 'assets/pics/shadow_of_the_beast2_karamoon.png');
game.load.spritesheet('button', 'assets/buttons/button_sprite_sheet.png', 193, 71);
game.load.start();
}
+2 -3
View File
@@ -1,10 +1,9 @@
/// <reference path="../../Phaser/Game.ts" />
/// <reference path="../../Phaser/ui/Button.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render);
function init() {
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
function preload() {
game.load.spritesheet('button', 'assets/buttons/button_sprite_sheet.png', 193, 71);
game.load.start();
}
var button;
var secondCam;
+3 -3
View File
@@ -3,12 +3,12 @@
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render);
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
function init() {
function preload() {
game.load.spritesheet('button', 'assets/buttons/button_sprite_sheet.png', 193, 71);
game.load.start();
}
+2 -3
View File
@@ -1,11 +1,10 @@
/// <reference path="../../Phaser/Game.ts" />
/// <reference path="../../Phaser/ui/Button.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update);
function init() {
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update);
function preload() {
game.load.image('beast', 'assets/pics/shadow_of_the_beast2_other_world.png');
game.load.atlas('button', 'assets/buttons/button_texture_atlas.png', 'assets/buttons/button_texture_atlas.json');
game.load.start();
}
image:
Phaser.Sprite
+3 -3
View File
@@ -3,13 +3,13 @@
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update);
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update);
function init() {
function preload() {
game.load.image('beast', 'assets/pics/shadow_of_the_beast2_other_world.png');
game.load.atlas('button', 'assets/buttons/button_texture_atlas.png', 'assets/buttons/button_texture_atlas.json');
game.load.start();
}
+2 -3
View File
@@ -1,10 +1,9 @@
/// <reference path="../../Phaser/Game.ts" />
/// <reference path="../../Plugins/CameraFX/Mirror.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update);
function init() {
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update);
function preload() {
game.load.image('backdrop', 'assets/pics/ninja-masters2.png');
game.load.start();
}
var mirror;
function create() {
+3 -3
View File
@@ -3,13 +3,13 @@
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update);
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update);
function init() {
function preload() {
game.load.image('backdrop', 'assets/pics/ninja-masters2.png');
game.load.start();
}
+2 -3
View File
@@ -1,10 +1,9 @@
/// <reference path="../../Phaser/Game.ts" />
/// <reference path="../../Plugins/CameraFX/Scanlines.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update);
function init() {
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update);
function preload() {
game.load.image('backdrop', 'assets/pics/ninja-masters2.png');
game.load.start();
}
var scanlines;
function create() {
+3 -3
View File
@@ -3,13 +3,13 @@
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update);
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update);
function init() {
function preload() {
game.load.image('backdrop', 'assets/pics/ninja-masters2.png');
game.load.start();
}
+3 -4
View File
@@ -1,13 +1,12 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
function init() {
game.world.setSize(1920, 1200, true);
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
function preload() {
game.load.image('backdrop', 'assets/pics/remember-me.jpg');
game.load.image('melon', 'assets/sprites/melon.png');
game.load.start();
}
function create() {
game.world.setSize(1920, 1200, true);
game.add.sprite(0, 0, 'backdrop');
for(var i = 0; i < 100; i++) {
game.add.sprite(game.world.randomX, game.world.randomY, 'melon');
+4 -6
View File
@@ -2,21 +2,19 @@
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
function init() {
game.world.setSize(1920, 1200, true);
function preload() {
game.load.image('backdrop', 'assets/pics/remember-me.jpg');
game.load.image('melon', 'assets/sprites/melon.png');
game.load.start();
}
function create() {
game.world.setSize(1920, 1200, true);
game.add.sprite(0, 0, 'backdrop');
for (var i = 0; i < 100; i++)
+2 -3
View File
@@ -1,9 +1,9 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update);
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update);
var ufo;
var speed = 4;
function init() {
function preload() {
game.world.setSize(1280, 600, true);
game.load.image('ground', 'assets/tests/ground-2x.png');
game.load.image('river', 'assets/tests/river-2x.png');
@@ -12,7 +12,6 @@
game.load.image('cloud1', 'assets/tests/cloud-narrow-2x.png');
game.load.image('cloud2', 'assets/tests/cloud-small-2x.png');
game.load.spritesheet('ufo', 'assets/sprites/ufo.png', 24, 21);
game.load.start();
}
function create() {
// background images
+3 -3
View File
@@ -1,11 +1,11 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update);
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update);
var ufo: Phaser.Sprite;
var speed: number = 4;
function init() {
function preload() {
game.world.setSize(1280, 600, true);
game.load.image('ground', 'assets/tests/ground-2x.png');
game.load.image('river', 'assets/tests/river-2x.png');
@@ -16,7 +16,7 @@
game.load.spritesheet('ufo', 'assets/sprites/ufo.png', 24, 21);
game.load.start();
}
function create() {
// background images
+2 -3
View File
@@ -1,10 +1,9 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
function init() {
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
function preload() {
game.load.image('grid', 'assets/tests/debug-grid-1920x1920.png');
game.load.image('car', 'assets/sprites/car90.png');
game.load.start();
}
var car;
var miniCam;
+3 -3
View File
@@ -2,14 +2,14 @@
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
function init() {
function preload() {
game.load.image('grid', 'assets/tests/debug-grid-1920x1920.png');
game.load.image('car', 'assets/sprites/car90.png');
game.load.start();
}
+2 -3
View File
@@ -1,14 +1,13 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render);
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
var btn1, btn2, btn3;
var fx;
function init() {
function preload() {
game.world.setSize(800, 600, true);
game.load.image('blue', 'assets/tests/blue-circle.png');
game.load.image('yellow', 'assets/tests/yellow-circle.png');
game.load.image('magenta', 'assets/tests/magenta-circle.png');
game.load.start();
}
function create() {
btn1 = game.add.button(114, 34, 'blue', simpleFade, this);
+3 -3
View File
@@ -1,19 +1,19 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render);
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
var btn1: Phaser.UI.Button,
btn2: Phaser.UI.Button,
btn3: Phaser.UI.Button;
var fx;
function init() {
function preload() {
game.world.setSize(800, 600, true);
game.load.image('blue', 'assets/tests/blue-circle.png');
game.load.image('yellow', 'assets/tests/yellow-circle.png');
game.load.image('magenta', 'assets/tests/magenta-circle.png');
game.load.start();
}
function create() {
btn1 = game.add.button(114, 34, 'blue', simpleFade, this);
+2 -3
View File
@@ -1,14 +1,13 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render);
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
var btn1, btn2, btn3;
var fx;
function init() {
function preload() {
game.world.setSize(800, 600, true);
game.load.image('blue', 'assets/tests/blue-circle.png');
game.load.image('yellow', 'assets/tests/yellow-circle.png');
game.load.image('magenta', 'assets/tests/magenta-circle.png');
game.load.start();
}
function create() {
btn1 = game.add.button(114, 34, 'blue', simpleFlash, this);
+3 -3
View File
@@ -1,19 +1,19 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render);
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
var btn1: Phaser.UI.Button,
btn2: Phaser.UI.Button,
btn3: Phaser.UI.Button;
var fx;
function init() {
function preload() {
game.world.setSize(800, 600, true);
game.load.image('blue', 'assets/tests/blue-circle.png');
game.load.image('yellow', 'assets/tests/yellow-circle.png');
game.load.image('magenta', 'assets/tests/magenta-circle.png');
game.load.start();
}
function create() {
btn1 = game.add.button(114, 34, 'blue', simpleFlash, this);
+2 -3
View File
@@ -1,14 +1,13 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render);
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
var btn1, btn2, btn3;
var fx;
function init() {
function preload() {
game.world.setSize(800, 600, true);
game.load.image('blue', 'assets/tests/blue-circle.png');
game.load.image('yellow', 'assets/tests/yellow-circle.png');
game.load.image('magenta', 'assets/tests/magenta-circle.png');
game.load.start();
}
function create() {
btn1 = game.add.button(114, 34, 'blue', simpleShake, this);
+3 -3
View File
@@ -1,19 +1,19 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render);
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
var btn1: Phaser.UI.Button,
btn2: Phaser.UI.Button,
btn3: Phaser.UI.Button;
var fx;
function init() {
function preload() {
game.world.setSize(800, 600, true);
game.load.image('blue', 'assets/tests/blue-circle.png');
game.load.image('yellow', 'assets/tests/yellow-circle.png');
game.load.image('magenta', 'assets/tests/magenta-circle.png');
game.load.start();
}
function create() {
btn1 = game.add.button(114, 34, 'blue', simpleShake, this);
+2 -3
View File
@@ -1,9 +1,8 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
function init() {
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
function preload() {
game.load.image('melon', 'assets/sprites/melon.png');
game.load.start();
}
var car;
var miniCam;
+3 -3
View File
@@ -2,13 +2,13 @@
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
function init() {
function preload() {
game.load.image('melon', 'assets/sprites/melon.png');
game.load.start();
}
+2 -3
View File
@@ -1,16 +1,15 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
var zombieCamera;
var zombie;
var walkSpeed = 2, direction = 1;
function init() {
function preload() {
game.world.setSize(1280, 600, true);
game.load.image('ground', 'assets/tests/ground-2x.png');
game.load.image('river', 'assets/tests/river-2x.png');
game.load.image('sky', 'assets/tests/sky-2x.png');
game.load.spritesheet('zombie', 'assets/sprites/metalslug_monster39x40.png', 39, 40);
game.load.start();
}
function create() {
// Add background images.
+3 -3
View File
@@ -1,6 +1,6 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
var zombieCamera: Phaser.Camera;
@@ -8,7 +8,7 @@
var walkSpeed: number = 2,
direction: number = 1;
function init() {
function preload() {
game.world.setSize(1280, 600, true);
game.load.image('ground', 'assets/tests/ground-2x.png');
game.load.image('river', 'assets/tests/river-2x.png');
@@ -16,7 +16,7 @@
game.load.spritesheet('zombie', 'assets/sprites/metalslug_monster39x40.png', 39, 40);
game.load.start();
}
function create() {
// Add background images.
+2 -3
View File
@@ -1,10 +1,9 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render);
function init() {
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
function preload() {
game.world.setSize(800, 600, true);
game.load.image('background', 'assets/misc/water_texture.jpg');
game.load.start();
}
function create() {
game.camera.texture.loadImage('background', false);
+3 -3
View File
@@ -1,12 +1,12 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render);
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
function init() {
function preload() {
game.world.setSize(800, 600, true);
game.load.image('background', 'assets/misc/water_texture.jpg');
game.load.start();
}
function create() {
game.camera.texture.loadImage('background', false);
+2 -3
View File
@@ -1,10 +1,10 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
var ufo, speed = 4;
var btn0, btn1, btn2, btn3;
var style = 'default';
function init() {
function preload() {
game.world.setSize(1280, 800, true);
game.load.image('ground', 'assets/tests/ground-2x.png');
game.load.image('river', 'assets/tests/river-2x.png');
@@ -14,7 +14,6 @@
game.load.image('cloud2', 'assets/tests/cloud-small-2x.png');
game.load.spritesheet('button', 'assets/buttons/follow-style-button.png', 224, 70);
game.load.spritesheet('ufo', 'assets/sprites/ufo.png', 24, 21);
game.load.start();
}
function create() {
// background images
+3 -3
View File
@@ -1,6 +1,6 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
var ufo: Phaser.Sprite,
speed: number = 4;
@@ -11,7 +11,7 @@
btn3: Phaser.UI.Button;
var style: string = 'default';
function init() {
function preload() {
game.world.setSize(1280, 800, true);
game.load.image('ground', 'assets/tests/ground-2x.png');
game.load.image('river', 'assets/tests/river-2x.png');
@@ -24,7 +24,7 @@
game.load.spritesheet('ufo', 'assets/sprites/ufo.png', 24, 21);
game.load.start();
}
function create() {
// background images
+2 -3
View File
@@ -1,14 +1,13 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
var radar;
var ships = [];
var enemyCamera;
function init() {
function preload() {
game.load.image('radar-surface', 'assets/tests/radar-surface.png');
game.load.image('ship', 'assets/sprites/asteroids_ship_white.png');
game.load.image('enemy-ship', 'assets/sprites/asteroids_ship.png');
game.load.start();
}
function create() {
// Add enemies and our ship the the world.
+3 -3
View File
@@ -1,20 +1,20 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
var radar: Phaser.Sprite;
var ships: Phaser.Sprite[] = [];
var enemyCamera: Phaser.Camera;
function init() {
function preload() {
game.load.image('radar-surface', 'assets/tests/radar-surface.png');
game.load.image('ship', 'assets/sprites/asteroids_ship_white.png');
game.load.image('enemy-ship', 'assets/sprites/asteroids_ship.png');
game.load.start();
}
function create() {
+2 -3
View File
@@ -1,16 +1,15 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
var zombieCamera;
var zombie;
var walkSpeed = 2, direction = 1;
function init() {
function preload() {
game.world.setSize(1280, 600, true);
game.load.image('ground', 'assets/tests/ground-2x.png');
game.load.image('river', 'assets/tests/river-2x.png');
game.load.image('sky', 'assets/tests/sky-2x.png');
game.load.spritesheet('zombie', 'assets/sprites/metalslug_monster39x40.png', 39, 40);
game.load.start();
}
function create() {
// Add background images.
+3 -3
View File
@@ -1,6 +1,6 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
var zombieCamera: Phaser.Camera;
@@ -8,7 +8,7 @@
var walkSpeed: number = 2,
direction: number = 1;
function init() {
function preload() {
game.world.setSize(1280, 600, true);
game.load.image('ground', 'assets/tests/ground-2x.png');
game.load.image('river', 'assets/tests/river-2x.png');
@@ -16,7 +16,7 @@
game.load.spritesheet('zombie', 'assets/sprites/metalslug_monster39x40.png', 39, 40);
game.load.start();
}
function create() {
// Add background images.
+2 -3
View File
@@ -1,11 +1,10 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
function init() {
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
function preload() {
game.world.setSize(1920, 1200, true);
game.load.image('backdrop', 'assets/pics/remember-me.jpg');
game.load.image('ball', 'assets/sprites/shinyball.png');
game.load.start();
}
function create() {
game.add.sprite(0, 0, 'backdrop');
+3 -3
View File
@@ -2,16 +2,16 @@
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
function init() {
function preload() {
game.world.setSize(1920, 1200, true);
game.load.image('backdrop', 'assets/pics/remember-me.jpg');
game.load.image('ball', 'assets/sprites/shinyball.png');
game.load.start();
}
+2 -3
View File
@@ -1,10 +1,9 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
function init() {
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
function preload() {
game.world.setSize(1600, 800, true);
game.load.image('disk', 'assets/pics/devilstar_demo_download_disk.png');
game.load.start();
}
function create() {
for(var i = 0; i < 10; i++) {
+3 -3
View File
@@ -2,15 +2,15 @@
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
function init() {
function preload() {
game.world.setSize(1600, 800, true);
game.load.image('disk', 'assets/pics/devilstar_demo_download_disk.png');
game.load.start();
}
+2 -3
View File
@@ -1,7 +1,7 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
function init() {
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
function preload() {
game.world.setSize(1280, 600, true);
game.load.image('ground', 'assets/tests/ground-2x.png');
game.load.image('river', 'assets/tests/river-2x.png');
@@ -9,7 +9,6 @@
game.load.image('cloud0', 'assets/tests/cloud-big-2x.png');
game.load.image('cloud1', 'assets/tests/cloud-narrow-2x.png');
game.load.image('cloud2', 'assets/tests/cloud-small-2x.png');
game.load.start();
}
function create() {
// background sky, which does not move at all
+3 -3
View File
@@ -1,7 +1,7 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
function init() {
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
function preload() {
game.world.setSize(1280, 600, true);
game.load.image('ground', 'assets/tests/ground-2x.png');
game.load.image('river', 'assets/tests/river-2x.png');
@@ -9,7 +9,7 @@
game.load.image('cloud0', 'assets/tests/cloud-big-2x.png');
game.load.image('cloud1', 'assets/tests/cloud-narrow-2x.png');
game.load.image('cloud2', 'assets/tests/cloud-small-2x.png');
game.load.start();
}
function create() {
// background sky, which does not move at all
+2 -3
View File
@@ -1,12 +1,11 @@
/// <reference path="../../Phaser/Game.ts" />
/// <reference path="../../Phaser/utils/DebugUtils.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
function init() {
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
function preload() {
game.world.setSize(1920, 1200, true);
game.load.image('backdrop', 'assets/pics/remember-me.jpg');
game.load.image('ball', 'assets/sprites/mana_card.png');
game.load.start();
}
var ball;
function create() {
+3 -3
View File
@@ -3,16 +3,16 @@
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
function init() {
function preload() {
game.world.setSize(1920, 1200, true);
game.load.image('backdrop', 'assets/pics/remember-me.jpg');
game.load.image('ball', 'assets/sprites/mana_card.png');
game.load.start();
}
+3 -3
View File
@@ -1,14 +1,14 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render);
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
var friendAndFoe: Phaser.Group,
enemies: Phaser.Group;
function init() {
function preload() {
game.load.image('ufo', 'assets/sprites/ufo.png');
game.load.image('baddie', 'assets/sprites/space-baddie.png');
game.load.start();
}
function create() {
// Create some local groups for later use.
+3 -3
View File
@@ -1,10 +1,10 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render);
function init() {
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
function preload() {
game.load.image('ufo', 'assets/sprites/ufo.png');
game.load.image('baddie', 'assets/sprites/space-baddie.png');
game.load.start();
}
var friendAndFoe: Phaser.Group,
+2 -3
View File
@@ -1,14 +1,13 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
function init() {
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
function preload() {
game.load.image('beast', 'assets/pics/shadow_of_the_beast2_karamoon.png');
game.load.image('snot', 'assets/pics/nslide_snot.png');
game.load.image('atari1', 'assets/sprites/atari130xe.png');
game.load.image('sonic', 'assets/sprites/sonic_havok_sanity.png');
game.load.image('coke', 'assets/sprites/cokecan.png');
game.load.image('disk', 'assets/sprites/oz_pov_melting_disk.png');
game.load.start();
}
var group1;
var group2;
+3 -3
View File
@@ -2,9 +2,9 @@
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
function init() {
function preload() {
game.load.image('beast', 'assets/pics/shadow_of_the_beast2_karamoon.png');
game.load.image('snot', 'assets/pics/nslide_snot.png');
@@ -12,7 +12,7 @@
game.load.image('sonic', 'assets/sprites/sonic_havok_sanity.png');
game.load.image('coke', 'assets/sprites/cokecan.png');
game.load.image('disk', 'assets/sprites/oz_pov_melting_disk.png');
game.load.start();
}
+3 -3
View File
@@ -1,11 +1,11 @@
(function() {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render);
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
var container: Phaser.Group;
function init() {
function preload() {
game.load.spritesheet('button', 'assets/buttons/number-buttons.png', 160, 160);
game.load.start();
}
function create() {
// Container for sorting the buttons, which we'll use to make buttons
+3 -3
View File
@@ -1,11 +1,11 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render);
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
function init() {
function preload() {
game.load.spritesheet('item', 'assets/buttons/number-buttons-90x90.png', 90, 90);
game.load.image('reviveBtn', 'assets/buttons/revive-button.png');
game.load.start();
}
function create() {
// Add some items.
+2 -3
View File
@@ -1,10 +1,9 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create);
function init() {
var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
function preload() {
// Using Phasers asset loader we load up a PNG from the assets folder
game.load.image('sonic', 'assets/sprites/sonic_havok_sanity.png');
game.load.start();
}
var firstGroup;
function create() {
+3 -3
View File
@@ -2,13 +2,13 @@
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create);
var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
function init() {
function preload() {
// Using Phasers asset loader we load up a PNG from the assets folder
game.load.image('sonic', 'assets/sprites/sonic_havok_sanity.png');
game.load.start();
}
+3 -3
View File
@@ -1,15 +1,15 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render);
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
// Left and right group.
var left:: Phaser.Group, right: Phaser.Group;
// The first selected item.
var selected: Phaser.Sprite = null;
function init() {
function preload() {
game.load.spritesheet('item', 'assets/buttons/number-buttons-90x90.png', 90, 90);
game.load.start();
}
function create() {
left = game.add.group();
+2 -3
View File
@@ -1,11 +1,10 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create);
function init() {
var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
function preload() {
game.load.image('atari1', 'assets/sprites/atari130xe.png');
game.load.image('atari2', 'assets/sprites/atari800xl.png');
game.load.image('card', 'assets/sprites/mana_card.png');
game.load.start();
}
var items;
var card;
+3 -3
View File
@@ -2,15 +2,15 @@
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create);
var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
function init() {
function preload() {
game.load.image('atari1', 'assets/sprites/atari130xe.png');
game.load.image('atari2', 'assets/sprites/atari800xl.png');
game.load.image('card', 'assets/sprites/mana_card.png');
game.load.start();
}
+3 -3
View File
@@ -1,12 +1,12 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
var baseAlphaIncSpeed: Number = 0.006;
function init() {
function preload() {
game.load.spritesheet('item', 'assets/buttons/number-buttons-90x90.png', 90, 90);
game.load.start();
}
function create() {
// Add some items.
+3 -3
View File
@@ -1,14 +1,14 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
var timer: Number,
cycle: Number;
function init() {
function preload() {
game.load.spritesheet('item', 'assets/buttons/number-buttons-90x90.png', 90, 90);
game.load.image('reviveBtn', 'assets/buttons/revive-button.png');
game.load.start();
}
function create() {
// Add some items.
+3 -3
View File
@@ -1,14 +1,14 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
var timer: Number,
cycle: Number;
function init() {
function preload() {
game.load.spritesheet('item', 'assets/buttons/number-buttons-90x90.png', 90, 90);
game.load.image('reviveBtn', 'assets/buttons/revive-button.png');
game.load.start();
}
function create() {
// Add some items.
+3 -3
View File
@@ -1,15 +1,15 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
var killTimer: Number,
reviveTimer: Number,
cycle: Number;
function init() {
function preload() {
game.load.spritesheet('item', 'assets/buttons/number-buttons-90x90.png', 90, 90);
game.load.image('reviveBtn', 'assets/buttons/revive-button.png');
game.load.start();
}
function create() {
// Add some items.
+3 -3
View File
@@ -1,7 +1,7 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render);
function init() {
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
function preload() {
game.world.setSize(1280, 800, true);
game.load.image('ground', 'assets/tests/ground-2x.png');
@@ -13,7 +13,7 @@
game.load.spritesheet('ufo', 'assets/sprites/ufo.png', 24, 21);
game.load.start();
}
function create() {
// Create the sky layer, behind everything and donot move.
+3 -3
View File
@@ -1,6 +1,6 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
var robot: Phaser.Group;
var eye: Phaser.Sprite,
@@ -10,14 +10,14 @@
leftLeg: Phaser.Sprite,
rightLeg: Phaser.Sprite;
function init() {
function preload() {
game.load.image('eye', 'assets/sprites/robot/eye.png');
game.load.image('body', 'assets/sprites/robot/body.png');
game.load.image('arm-l', 'assets/sprites/robot/arm-l.png');
game.load.image('arm-r', 'assets/sprites/robot/arm-r.png');
game.load.image('leg-l', 'assets/sprites/robot/leg-l.png');
game.load.image('leg-r', 'assets/sprites/robot/leg-r.png');
game.load.start();
}
function create() {
// Add some items.
+3 -3
View File
@@ -1,6 +1,6 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
var robot: Phaser.Group;
var eye: Phaser.Sprite,
@@ -10,7 +10,7 @@
leftLeg: Phaser.Sprite,
rightLeg: Phaser.Sprite;
function init() {
function preload() {
game.load.image('eye', 'assets/sprites/robot/eye.png');
game.load.image('body', 'assets/sprites/robot/body.png');
game.load.image('arm-l', 'assets/sprites/robot/arm-l.png');
@@ -18,7 +18,7 @@
game.load.image('leg-l', 'assets/sprites/robot/leg-l.png');
game.load.image('leg-r', 'assets/sprites/robot/leg-r.png');
game.load.start();
}
function create() {
// Add some items.
+3 -3
View File
@@ -1,6 +1,6 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
var robot: Phaser.Group;
var eye: Phaser.Sprite,
@@ -10,7 +10,7 @@
leftLeg: Phaser.Sprite,
rightLeg: Phaser.Sprite;
function init() {
function preload() {
game.load.image('eye', 'assets/sprites/robot/eye.png');
game.load.image('body', 'assets/sprites/robot/body.png');
game.load.image('arm-l', 'assets/sprites/robot/arm-l.png');
@@ -18,7 +18,7 @@
game.load.image('leg-l', 'assets/sprites/robot/leg-l.png');
game.load.image('leg-r', 'assets/sprites/robot/leg-r.png');
game.load.start();
}
function create() {
// Add some items.
+3 -3
View File
@@ -1,15 +1,15 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render);
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
var friendAndFoe: Phaser.Group,
enemies: Phaser.Group;
function init() {
function preload() {
game.load.image('ufo', 'assets/sprites/ufo.png');
game.load.image('baddie', 'assets/sprites/space-baddie.png');
game.load.spritesheet('button', 'assets/buttons/baddie-buttons.png', 224, 70);
game.load.start();
}
function create() {
// Create some local groups for later use.
+3 -3
View File
@@ -1,15 +1,15 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render);
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
var friendAndFoe: Phaser.Group,
enemies: Phaser.Group;
function init() {
function preload() {
game.load.image('ufo', 'assets/sprites/ufo.png');
game.load.image('baddie', 'assets/sprites/space-baddie.png');
game.load.spritesheet('button', 'assets/buttons/baddie-buttons.png', 224, 70);
game.load.start();
}
function create() {
// Create some local groups for later use.
+3 -3
View File
@@ -1,15 +1,15 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
// Group contains items.
var items: Phaser.Group;
function init() {
function preload() {
game.load.spritesheet('item', 'assets/buttons/number-buttons-90x90.png', 90, 90);
game.load.image('rect', 'assets/tests/200x100corners.png');
game.load.image('rect2', 'assets/tests/200x100corners2.png');
game.load.start();
}
function create() {
// Create item container group.
+3 -3
View File
@@ -1,15 +1,15 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
// Left and right group.
var left: Phaser.Group, right: Phaser.Group;
// The first selected item.
var selected: Phaser.Sprite = null;
function init() {
function preload() {
game.load.spritesheet('item', 'assets/buttons/number-buttons-90x90.png', 90, 90);
game.load.start();
}
function create() {
left = game.add.group();
+3 -3
View File
@@ -1,12 +1,12 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render);
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
var baseIncSpeed: Number = 0.006;
function init() {
function preload() {
game.load.spritesheet('item', 'assets/buttons/number-buttons-90x90.png', 90, 90);
game.load.start();
}
function create() {
// Add some items.
+3 -3
View File
@@ -1,13 +1,13 @@
(function() {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
var xTop: Phaser.Group,
yTop: Phaser.Group,
zTop: Phaser.Group;
function init() {
function preload() {
game.load.image('cell', 'assets/sprites/diamond.png');
game.load.start();
}
function create() {
// Create 3 groups which will have different sort "index".
+3 -3
View File
@@ -1,13 +1,13 @@
(function() {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
// Wabbits inside this group is sorted by its "dead" property.
// Dead wabbits behinds the others.
var wabbits: Phaser.Group;
function init() {
function preload() {
game.load.image('wabbit', 'assets/sprites/wabbit.png');
game.load.start();
}
function create() {
// Create container group.
+3 -3
View File
@@ -1,6 +1,6 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render);
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
// Groups for storing friends and enemies, may use for collision later.
var friendAndFoe: Phaser.Group,
@@ -10,11 +10,11 @@
var normalBaddies: Phaser.Group,
purpleBaddies: Phaser.Group;
function init() {
function preload() {
game.load.image('ufo', 'assets/sprites/ufo.png');
game.load.image('baddie', 'assets/sprites/space-baddie.png');
game.load.image('purple-baddie', 'assets/sprites/space-baddie-purple.png');
game.load.start();
}
function create() {
// Create some local groups for later use.
+2 -3
View File
@@ -1,10 +1,9 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create);
function init() {
var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
function preload() {
game.load.image('atari1', 'assets/sprites/atari130xe.png');
game.load.image('atari2', 'assets/sprites/atari800xl.png');
game.load.start();
}
var atari1;
var atari2;
+3 -3
View File
@@ -2,14 +2,14 @@
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create);
var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
function init() {
function preload() {
game.load.image('atari1', 'assets/sprites/atari130xe.png');
game.load.image('atari2', 'assets/sprites/atari800xl.png');
game.load.start();
}

Some files were not shown because too many files have changed in this diff Show More