2013-08-08 18:16:47 +00:00
|
|
|
/// <reference path="_definitions.ts" />
|
2013-04-12 16:19:56 +00:00
|
|
|
|
2013-04-18 13:16:18 +00:00
|
|
|
/**
|
2013-08-09 02:12:33 +00:00
|
|
|
* State
|
|
|
|
*
|
|
|
|
* This is a base State class which can be extended if you are creating your game with TypeScript.
|
|
|
|
* It provides quick access to common functions such as the camera, cache, input, match, sound and more.
|
|
|
|
*
|
|
|
|
* @package Phaser.State
|
|
|
|
* @author Richard Davey <rich@photonstorm.com>
|
|
|
|
* @copyright 2013 Photon Storm Ltd.
|
|
|
|
* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
|
|
|
|
module Phaser {
|
|
|
|
|
|
|
|
export class State {
|
|
|
|
|
2013-05-03 11:12:12 +00:00
|
|
|
/**
|
|
|
|
* State constructor
|
|
|
|
* Create a new <code>State</code>.
|
|
|
|
*/
|
2013-08-08 18:16:47 +00:00
|
|
|
constructor(game: Phaser.Game) {
|
2013-04-18 13:16:18 +00:00
|
|
|
|
|
|
|
this.game = game;
|
|
|
|
|
2013-05-22 23:01:58 +00:00
|
|
|
this.add = game.add;
|
2013-04-18 13:16:18 +00:00
|
|
|
this.camera = game.camera;
|
|
|
|
this.cache = game.cache;
|
|
|
|
this.input = game.input;
|
2013-06-05 01:58:16 +00:00
|
|
|
this.load = game.load;
|
2013-04-18 13:16:18 +00:00
|
|
|
this.math = game.math;
|
|
|
|
this.sound = game.sound;
|
|
|
|
this.stage = game.stage;
|
|
|
|
this.time = game.time;
|
|
|
|
this.tweens = game.tweens;
|
|
|
|
this.world = game.world;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-05-03 11:12:12 +00:00
|
|
|
/**
|
|
|
|
* Reference to Game.
|
|
|
|
*/
|
2013-08-08 18:16:47 +00:00
|
|
|
public game: Phaser.Game;
|
2013-04-18 13:16:18 +00:00
|
|
|
|
2013-05-03 11:12:12 +00:00
|
|
|
/**
|
|
|
|
* Currently used camera.
|
|
|
|
* @type {Camera}
|
|
|
|
*/
|
2013-08-08 18:16:47 +00:00
|
|
|
public camera: Phaser.Camera;
|
2013-05-16 01:36:58 +00:00
|
|
|
|
2013-05-03 11:12:12 +00:00
|
|
|
/**
|
|
|
|
* Reference to the assets cache.
|
|
|
|
* @type {Cache}
|
|
|
|
*/
|
2013-08-08 18:16:47 +00:00
|
|
|
public cache: Phaser.Cache;
|
2013-05-16 01:36:58 +00:00
|
|
|
|
2013-05-22 23:01:58 +00:00
|
|
|
/**
|
|
|
|
* Reference to the GameObject Factory.
|
|
|
|
* @type {GameObjectFactory}
|
|
|
|
*/
|
2013-08-08 18:16:47 +00:00
|
|
|
public add: Phaser.GameObjectFactory;
|
2013-05-22 23:01:58 +00:00
|
|
|
|
2013-05-03 11:12:12 +00:00
|
|
|
/**
|
|
|
|
* Reference to the input manager
|
|
|
|
* @type {Input}
|
|
|
|
*/
|
2013-08-08 18:16:47 +00:00
|
|
|
public input: Phaser.InputManager;
|
2013-05-16 01:36:58 +00:00
|
|
|
|
2013-05-03 11:12:12 +00:00
|
|
|
/**
|
|
|
|
* Reference to the assets loader.
|
|
|
|
* @type {Loader}
|
|
|
|
*/
|
2013-08-08 18:16:47 +00:00
|
|
|
public load: Phaser.Loader;
|
2013-05-16 01:36:58 +00:00
|
|
|
|
2013-05-03 11:12:12 +00:00
|
|
|
/**
|
|
|
|
* Reference to the math helper.
|
|
|
|
* @type {GameMath}
|
|
|
|
*/
|
2013-08-08 18:16:47 +00:00
|
|
|
public math: Phaser.GameMath;
|
2013-05-16 01:36:58 +00:00
|
|
|
|
2013-05-03 11:12:12 +00:00
|
|
|
/**
|
|
|
|
* Reference to the sound manager.
|
|
|
|
* @type {SoundManager}
|
|
|
|
*/
|
2013-08-08 18:16:47 +00:00
|
|
|
public sound: Phaser.SoundManager;
|
2013-05-16 01:36:58 +00:00
|
|
|
|
2013-05-03 11:12:12 +00:00
|
|
|
/**
|
|
|
|
* Reference to the stage.
|
|
|
|
* @type {Stage}
|
|
|
|
*/
|
2013-08-08 18:16:47 +00:00
|
|
|
public stage: Phaser.Stage;
|
2013-05-16 01:36:58 +00:00
|
|
|
|
2013-05-03 11:12:12 +00:00
|
|
|
/**
|
|
|
|
* Reference to game clock.
|
|
|
|
* @type {Time}
|
|
|
|
*/
|
2013-08-08 18:16:47 +00:00
|
|
|
public time: Phaser.TimeManager;
|
2013-05-16 01:36:58 +00:00
|
|
|
|
2013-05-03 11:12:12 +00:00
|
|
|
/**
|
|
|
|
* Reference to the tween manager.
|
|
|
|
* @type {TweenManager}
|
|
|
|
*/
|
2013-08-08 18:16:47 +00:00
|
|
|
public tweens: Phaser.TweenManager;
|
2013-05-16 01:36:58 +00:00
|
|
|
|
2013-05-03 11:12:12 +00:00
|
|
|
/**
|
|
|
|
* Reference to the world.
|
|
|
|
* @type {World}
|
|
|
|
*/
|
2013-08-08 18:16:47 +00:00
|
|
|
public world: Phaser.World;
|
2013-04-18 13:16:18 +00:00
|
|
|
|
2013-05-16 01:36:58 +00:00
|
|
|
// Override these in your own States
|
2013-04-18 13:16:18 +00:00
|
|
|
|
2013-05-03 11:12:12 +00:00
|
|
|
/**
|
|
|
|
* Override this method to add some load operations.
|
|
|
|
* If you need to use the loader, you may need to use them here.
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
public init() { }
|
2013-05-16 01:36:58 +00:00
|
|
|
|
2013-05-03 11:12:12 +00:00
|
|
|
/**
|
|
|
|
* This method is called after the game engine successfully switches states.
|
|
|
|
* Feel free to add any setup code here.(Do not load anything here, override init() instead)
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
public create() { }
|
2013-05-16 01:36:58 +00:00
|
|
|
|
2013-05-03 11:12:12 +00:00
|
|
|
/**
|
|
|
|
* Put update logic here.
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
public update() { }
|
2013-05-16 01:36:58 +00:00
|
|
|
|
2013-05-03 11:12:12 +00:00
|
|
|
/**
|
|
|
|
* Put render operations here.
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
public render() { }
|
2013-05-16 01:36:58 +00:00
|
|
|
|
2013-05-03 11:12:12 +00:00
|
|
|
/**
|
|
|
|
* This method will be called when game paused.
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
public paused() { }
|
|
|
|
|
2013-05-16 01:36:58 +00:00
|
|
|
/**
|
|
|
|
* This method will be called when the state is destroyed
|
|
|
|
*/
|
|
|
|
public destroy() { }
|
|
|
|
|
2013-05-03 11:12:12 +00:00
|
|
|
/**
|
2013-05-23 02:08:57 +00:00
|
|
|
* Checks for overlaps between two objects using the world QuadTree. Can be GameObject vs. GameObject, GameObject vs. Group or Group vs. Group.
|
|
|
|
* Note: Does not take the objects scrollFactor into account. All overlaps are check in world space.
|
|
|
|
* @param object1 The first GameObject or Group to check. If null the world.group is used.
|
|
|
|
* @param object2 The second GameObject or Group to check.
|
|
|
|
* @param notifyCallback A callback function that is called if the objects overlap. The two objects will be passed to this function in the same order in which you passed them to Collision.overlap.
|
|
|
|
* @param processCallback A callback function that lets you perform additional checks against the two objects if they overlap. If this is set then notifyCallback will only be called if processCallback returns true.
|
|
|
|
* @param context The context in which the callbacks will be called
|
2013-08-13 03:22:24 +00:00
|
|
|
* @returns {bool} true if the objects overlap, otherwise false.
|
2013-05-23 02:08:57 +00:00
|
|
|
*/
|
2013-08-13 03:22:24 +00:00
|
|
|
//public collide(objectOrGroup1 = null, objectOrGroup2 = null, notifyCallback = null, context? = this.game.callbackContext): bool {
|
2013-05-29 01:58:56 +00:00
|
|
|
// return this.collision.overlap(objectOrGroup1, objectOrGroup2, notifyCallback, Collision.separate, context);
|
|
|
|
//}
|
2013-04-12 16:19:56 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|