mirror of
https://github.com/wassname/phaser.git
synced 2026-07-12 00:50:45 +08:00
Clearing down the To Do list.
This commit is contained in:
+22
-95
@@ -17,17 +17,17 @@
|
||||
/// <reference path="sound/SoundManager.ts" />
|
||||
/// <reference path="sound/Sound.ts" />
|
||||
/// <reference path="Stage.ts" />
|
||||
/// <reference path="Time.ts" />
|
||||
/// <reference path="time/TimeManager.ts" />
|
||||
/// <reference path="tweens/TweenManager.ts" />
|
||||
/// <reference path="World.ts" />
|
||||
/// <reference path="system/Device.ts" />
|
||||
/// <reference path="system/RequestAnimationFrame.ts" />
|
||||
/// <reference path="input/Input.ts" />
|
||||
/// <reference path="input/InputManager.ts" />
|
||||
/// <reference path="renderers/IRenderer.ts" />
|
||||
/// <reference path="renderers/HeadlessRenderer.ts" />
|
||||
/// <reference path="renderers/CanvasRenderer.ts" />
|
||||
/// <reference path="utils/DebugUtils.ts" />
|
||||
/// <reference path="../Plugins/IPlugin.ts" />
|
||||
/// <reference path="core/PluginManager.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Game
|
||||
@@ -71,13 +71,10 @@ module Phaser {
|
||||
|
||||
if (document.readyState === 'complete' || document.readyState === 'interactive')
|
||||
{
|
||||
//setTimeout(() => this.boot(parent, width, height));
|
||||
setTimeout(() => Phaser.GAMES[this.id].boot(parent, width, height));
|
||||
}
|
||||
else
|
||||
{
|
||||
//document.addEventListener('DOMContentLoaded', () => this.boot(parent, width, height), false);
|
||||
//window.addEventListener('load', () => this.boot(parent, width, height), false);
|
||||
document.addEventListener('DOMContentLoaded', Phaser.GAMES[this.id].boot(parent, width, height), false);
|
||||
window.addEventListener('load', Phaser.GAMES[this.id].boot(parent, width, height), false);
|
||||
}
|
||||
@@ -116,22 +113,10 @@ module Phaser {
|
||||
private _pendingState = null;
|
||||
|
||||
/**
|
||||
* Plugin loop pointer
|
||||
* @type {number}
|
||||
* The PluginManager for the Game
|
||||
* @type {PluginManager}
|
||||
*/
|
||||
private _p: number;
|
||||
|
||||
/**
|
||||
* Plugins array counter
|
||||
* @type {number}
|
||||
*/
|
||||
private _pluginsLength: number;
|
||||
|
||||
/**
|
||||
* An Array of Phaser Plugins
|
||||
* @type {Array}
|
||||
*/
|
||||
public plugins: Phaser.IPlugin[];
|
||||
public plugins: PluginManager;
|
||||
|
||||
/**
|
||||
* The current State object (defaults to null)
|
||||
@@ -214,7 +199,7 @@ module Phaser {
|
||||
* Reference to the input manager
|
||||
* @type {Input}
|
||||
*/
|
||||
public input: Input;
|
||||
public input: InputManager;
|
||||
|
||||
/**
|
||||
* Reference to the assets loader.
|
||||
@@ -250,7 +235,7 @@ module Phaser {
|
||||
* Reference to game clock.
|
||||
* @type {Time}
|
||||
*/
|
||||
public time: Time;
|
||||
public time: TimeManager;
|
||||
|
||||
/**
|
||||
* Reference to the tween manager.
|
||||
@@ -315,7 +300,6 @@ module Phaser {
|
||||
|
||||
if (!document.body)
|
||||
{
|
||||
//window.setTimeout(() => this.boot(parent, width, height), 13);
|
||||
setTimeout(() => Phaser.GAMES[this.id].boot(parent, width, height), 13);
|
||||
}
|
||||
else
|
||||
@@ -331,12 +315,13 @@ module Phaser {
|
||||
this.add = new GameObjectFactory(this);
|
||||
this.cache = new Cache(this);
|
||||
this.load = new Loader(this, this.loadComplete);
|
||||
this.time = new Time(this);
|
||||
this.time = new TimeManager(this);
|
||||
this.tweens = new TweenManager(this);
|
||||
this.input = new Input(this);
|
||||
this.input = new InputManager(this);
|
||||
this.sound = new SoundManager(this);
|
||||
this.rnd = new RandomDataGenerator([(Date.now() * Math.random()).toString()]);
|
||||
this.physics = new Physics.Manager(this);
|
||||
this.plugins = new PluginManager(this, this);
|
||||
|
||||
this.setRenderer(Phaser.Types.RENDERER_CANVAS);
|
||||
|
||||
@@ -396,30 +381,6 @@ module Phaser {
|
||||
|
||||
}
|
||||
|
||||
public addPlugin(plugin) {
|
||||
|
||||
// Prototype?
|
||||
if (typeof plugin === 'function')
|
||||
{
|
||||
this.plugins.push(new plugin(this));
|
||||
}
|
||||
else
|
||||
{
|
||||
plugin.game = this;
|
||||
this.plugins.push(plugin);
|
||||
}
|
||||
|
||||
this._pluginsLength++;
|
||||
|
||||
}
|
||||
|
||||
public removePlugin(plugin: Phaser.IPlugin) {
|
||||
|
||||
// TODO :)
|
||||
this._pluginsLength--;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the load has finished after init was run.
|
||||
*/
|
||||
@@ -455,25 +416,24 @@ module Phaser {
|
||||
|
||||
}
|
||||
|
||||
private emptyCallback() {
|
||||
// Called by onUpdateCallback etc
|
||||
}
|
||||
|
||||
/**
|
||||
* Game loop method will be called when it's running.
|
||||
*/
|
||||
private loop() {
|
||||
|
||||
for (this._p = 0; this._p < this._pluginsLength; this._p++)
|
||||
{
|
||||
if (this.plugins[this._p].active)
|
||||
{
|
||||
this.plugins[this._p].preUpdate();
|
||||
}
|
||||
}
|
||||
this.plugins.preUpdate();
|
||||
|
||||
this.tweens.update();
|
||||
this.input.update();
|
||||
this.stage.update();
|
||||
this.sound.update();
|
||||
this.physics.update();
|
||||
//this.physics.update();
|
||||
this.world.update();
|
||||
this.plugins.update();
|
||||
|
||||
if (this._loadComplete && this.onUpdateCallback)
|
||||
{
|
||||
@@ -486,21 +446,8 @@ module Phaser {
|
||||
|
||||
this.world.postUpdate();
|
||||
|
||||
for (this._p = 0; this._p < this._pluginsLength; this._p++)
|
||||
{
|
||||
if (this.plugins[this._p].active)
|
||||
{
|
||||
this.plugins[this._p].postUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
for (this._p = 0; this._p < this._pluginsLength; this._p++)
|
||||
{
|
||||
if (this.plugins[this._p].visible)
|
||||
{
|
||||
this.plugins[this._p].preRender();
|
||||
}
|
||||
}
|
||||
this.plugins.postUpdate();
|
||||
this.plugins.preRender();
|
||||
|
||||
if (this._loadComplete && this.onPreRenderCallback)
|
||||
{
|
||||
@@ -508,6 +455,7 @@ module Phaser {
|
||||
}
|
||||
|
||||
this.renderer.render();
|
||||
this.plugins.render();
|
||||
|
||||
if (this._loadComplete && this.onRenderCallback)
|
||||
{
|
||||
@@ -518,13 +466,7 @@ module Phaser {
|
||||
this.onLoadRenderCallback.call(this.callbackContext);
|
||||
}
|
||||
|
||||
for (this._p = 0; this._p < this._pluginsLength; this._p++)
|
||||
{
|
||||
if (this.plugins[this._p].visible)
|
||||
{
|
||||
this.plugins[this._p].postRender();
|
||||
}
|
||||
}
|
||||
this.plugins.postRender();
|
||||
|
||||
}
|
||||
|
||||
@@ -747,21 +689,6 @@ module Phaser {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @returns {boolean} true if the objects overlap, otherwise false.
|
||||
*/
|
||||
public collide(objectOrGroup1 = null, objectOrGroup2 = null, notifyCallback = null, context? = this.callbackContext): bool {
|
||||
//return this.world.physics.overlap(objectOrGroup1, objectOrGroup2, notifyCallback, this.world.physics.separate, context);
|
||||
return false;
|
||||
}
|
||||
|
||||
public get camera(): Camera {
|
||||
return this.world.cameras.current;
|
||||
}
|
||||
|
||||
+76
-76
@@ -58,67 +58,65 @@
|
||||
</PropertyGroup>
|
||||
<ItemGroup />
|
||||
<ItemGroup>
|
||||
<Content Include="components\animation\AnimationManager.js">
|
||||
<TypeScriptCompile Include="animation\Animation.ts" />
|
||||
<Content Include="animation\Animation.js">
|
||||
<DependentUpon>Animation.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="animation\Frame.ts" />
|
||||
<TypeScriptCompile Include="animation\AnimationManager.ts" />
|
||||
<Content Include="animation\AnimationManager.js">
|
||||
<DependentUpon>AnimationManager.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="animation\Frame.js">
|
||||
<DependentUpon>Frame.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="animation\FrameData.ts" />
|
||||
<Content Include="animation\FrameData.js">
|
||||
<DependentUpon>FrameData.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="Game.ts" />
|
||||
<TypeScriptCompile Include="components\sprite\Events.ts" />
|
||||
<TypeScriptCompile Include="components\sprite\Debug.ts" />
|
||||
<TypeScriptCompile Include="components\CSS3Filters.ts" />
|
||||
<Content Include="components\CSS3Filters.js">
|
||||
<TypeScriptCompile Include="core\PluginManager.ts" />
|
||||
<TypeScriptCompile Include="core\Plugin.ts" />
|
||||
<Content Include="core\Plugin.js">
|
||||
<DependentUpon>Plugin.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="core\PluginManager.js">
|
||||
<DependentUpon>PluginManager.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="display\CSS3Filters.ts" />
|
||||
<Content Include="display\CSS3Filters.js">
|
||||
<DependentUpon>CSS3Filters.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="components\sprite\Debug.js">
|
||||
<DependentUpon>Debug.ts</DependentUpon>
|
||||
<TypeScriptCompile Include="display\Texture.ts" />
|
||||
<TypeScriptCompile Include="display\DynamicTexture.ts" />
|
||||
<Content Include="display\DynamicTexture.js">
|
||||
<DependentUpon>DynamicTexture.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="components\sprite\Events.js">
|
||||
<DependentUpon>Events.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="components\sprite\Input.ts" />
|
||||
<Content Include="components\sprite\Input.js">
|
||||
<DependentUpon>Input.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="components\Texture.ts" />
|
||||
<Content Include="components\Texture.js">
|
||||
<Content Include="display\Texture.js">
|
||||
<DependentUpon>Texture.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="components\Tile.ts" />
|
||||
<Content Include="components\TilemapLayer.ts" />
|
||||
<TypeScriptCompile Include="components\Transform.ts" />
|
||||
<Content Include="components\Transform.js">
|
||||
<DependentUpon>Transform.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="Game.js">
|
||||
<DependentUpon>Game.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="components\camera\CameraFX.ts" />
|
||||
<Content Include="components\camera\CameraFX.js">
|
||||
<DependentUpon>CameraFX.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="components\ScrollRegion.ts" />
|
||||
<TypeScriptCompile Include="gameobjects\Button.ts" />
|
||||
<Content Include="gameobjects\Button.js">
|
||||
<DependentUpon>Button.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="gameobjects\DynamicTexture.js">
|
||||
<DependentUpon>DynamicTexture.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="gameobjects\Sprite.ts" />
|
||||
<TypeScriptCompile Include="gameobjects\IGameObject.ts" />
|
||||
<TypeScriptCompile Include="gameobjects\Emitter.ts" />
|
||||
<Content Include="gameobjects\Emitter.js">
|
||||
<DependentUpon>Emitter.ts</DependentUpon>
|
||||
<TypeScriptCompile Include="gameobjects\Events.ts" />
|
||||
<Content Include="gameobjects\Events.js">
|
||||
<DependentUpon>Events.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="gameobjects\IGameObject.js">
|
||||
<DependentUpon>IGameObject.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="gameobjects\ScrollZone.ts" />
|
||||
<Content Include="gameobjects\Particle.ts" />
|
||||
<TypeScriptCompile Include="gameobjects\Tilemap.ts" />
|
||||
<Content Include="gameobjects\Tilemap.js">
|
||||
<DependentUpon>Tilemap.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="geom\Circle.ts" />
|
||||
<TypeScriptCompile Include="gameobjects\ScrollRegion.ts" />
|
||||
<Content Include="gameobjects\ScrollRegion.js">
|
||||
<DependentUpon>ScrollRegion.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="gameobjects\TransformManager.ts" />
|
||||
<Content Include="gameobjects\TransformManager.js">
|
||||
<DependentUpon>TransformManager.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="geom\Circle.js">
|
||||
<DependentUpon>Circle.ts</DependentUpon>
|
||||
</Content>
|
||||
@@ -134,6 +132,14 @@
|
||||
<Content Include="geom\Rectangle.js">
|
||||
<DependentUpon>Rectangle.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="input\InputManager.ts" />
|
||||
<TypeScriptCompile Include="input\InputHandler.ts" />
|
||||
<Content Include="input\InputHandler.js">
|
||||
<DependentUpon>InputHandler.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="input\InputManager.js">
|
||||
<DependentUpon>InputManager.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="math\GameMath.js">
|
||||
<DependentUpon>GameMath.ts</DependentUpon>
|
||||
</Content>
|
||||
@@ -166,14 +172,6 @@
|
||||
<DependentUpon>LinkedList.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="math\Vec2.ts" />
|
||||
<TypeScriptCompile Include="math\Transform.ts" />
|
||||
<Content Include="math\Transform.js">
|
||||
<DependentUpon>Transform.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="math\TransformUtils.ts" />
|
||||
<Content Include="math\TransformUtils.js">
|
||||
<DependentUpon>TransformUtils.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="math\Vec2.js">
|
||||
<DependentUpon>Vec2.ts</DependentUpon>
|
||||
</Content>
|
||||
@@ -182,6 +180,14 @@
|
||||
<DependentUpon>Net.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="physics\arcade\ArcadePhysics.ts" />
|
||||
<TypeScriptCompile Include="particles\ArcadeEmitter.ts" />
|
||||
<Content Include="particles\ArcadeEmitter.js">
|
||||
<DependentUpon>ArcadeEmitter.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="particles\ArcadeParticle.ts" />
|
||||
<Content Include="particles\ArcadeParticle.js">
|
||||
<DependentUpon>ArcadeParticle.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="physics\advanced\readme.txt" />
|
||||
<Content Include="physics\arcade\ArcadePhysics.js">
|
||||
<DependentUpon>ArcadePhysics.ts</DependentUpon>
|
||||
@@ -215,10 +221,29 @@
|
||||
<Content Include="system\screens\OrientationScreen.js">
|
||||
<DependentUpon>OrientationScreen.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="tilemap\Tile.ts" />
|
||||
<Content Include="tilemap\Tile.js">
|
||||
<DependentUpon>Tile.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="tilemap\TilemapLayer.ts" />
|
||||
<TypeScriptCompile Include="tilemap\Tilemap.ts" />
|
||||
<Content Include="tilemap\Tilemap.js">
|
||||
<DependentUpon>Tilemap.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="tilemap\TilemapLayer.js">
|
||||
<DependentUpon>TilemapLayer.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="ui\Button.ts" />
|
||||
<TypeScriptCompile Include="time\TimeManager.ts" />
|
||||
<Content Include="time\TimeManager.js">
|
||||
<DependentUpon>TimeManager.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="ui\Button.js">
|
||||
<DependentUpon>Button.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="utils\CircleUtils.js">
|
||||
<DependentUpon>CircleUtils.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="utils\PixelUtils.ts" />
|
||||
<TypeScriptCompile Include="utils\ColorUtils.ts" />
|
||||
<Content Include="utils\ColorUtils.js">
|
||||
<DependentUpon>ColorUtils.ts</DependentUpon>
|
||||
@@ -227,9 +252,6 @@
|
||||
<Content Include="utils\DebugUtils.js">
|
||||
<DependentUpon>DebugUtils.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="utils\PixelUtils.js">
|
||||
<DependentUpon>PixelUtils.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="utils\PointUtils.js">
|
||||
<DependentUpon>PointUtils.ts</DependentUpon>
|
||||
</Content>
|
||||
@@ -237,9 +259,6 @@
|
||||
<Content Include="utils\RectangleUtils.js">
|
||||
<DependentUpon>RectangleUtils.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="math\IntersectResult.js">
|
||||
<DependentUpon>IntersectResult.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="math\Vec2Utils.ts" />
|
||||
<Content Include="math\Vec2Utils.js">
|
||||
<DependentUpon>Vec2Utils.ts</DependentUpon>
|
||||
@@ -272,18 +291,9 @@
|
||||
</Content>
|
||||
<TypeScriptCompile Include="sound\Sound.ts" />
|
||||
<TypeScriptCompile Include="sound\SoundManager.ts" />
|
||||
<Content Include="components\animation\Animation.js">
|
||||
<DependentUpon>Animation.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="loader\AnimationLoader.js">
|
||||
<DependentUpon>AnimationLoader.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="components\animation\Frame.js">
|
||||
<DependentUpon>Frame.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="components\animation\FrameData.js">
|
||||
<DependentUpon>FrameData.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="cameras\Camera.js">
|
||||
<DependentUpon>Camera.ts</DependentUpon>
|
||||
</Content>
|
||||
@@ -368,11 +378,7 @@
|
||||
<TypeScriptCompile Include="tweens\easing\Circular.ts" />
|
||||
<TypeScriptCompile Include="tweens\easing\Bounce.ts" />
|
||||
<TypeScriptCompile Include="tweens\easing\Back.ts" />
|
||||
<TypeScriptCompile Include="components\animation\FrameData.ts" />
|
||||
<TypeScriptCompile Include="components\animation\Frame.ts" />
|
||||
<TypeScriptCompile Include="loader\AnimationLoader.ts" />
|
||||
<TypeScriptCompile Include="components\animation\Animation.ts" />
|
||||
<TypeScriptCompile Include="math\IntersectResult.ts" />
|
||||
<Content Include="core\Group.js">
|
||||
<DependentUpon>Group.ts</DependentUpon>
|
||||
</Content>
|
||||
@@ -394,9 +400,6 @@
|
||||
<Content Include="State.js">
|
||||
<DependentUpon>State.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="Time.js">
|
||||
<DependentUpon>Time.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="tweens\TweenManager.js">
|
||||
<DependentUpon>TweenManager.ts</DependentUpon>
|
||||
</Content>
|
||||
@@ -409,7 +412,6 @@
|
||||
</Content>
|
||||
<TypeScriptCompile Include="World.ts" />
|
||||
<TypeScriptCompile Include="tweens\TweenManager.ts" />
|
||||
<TypeScriptCompile Include="Time.ts" />
|
||||
<TypeScriptCompile Include="State.ts" />
|
||||
<TypeScriptCompile Include="Stage.ts" />
|
||||
<TypeScriptCompile Include="core\SignalBinding.ts" />
|
||||
@@ -418,8 +420,6 @@
|
||||
<TypeScriptCompile Include="loader\Loader.ts" />
|
||||
<TypeScriptCompile Include="core\Group.ts" />
|
||||
<TypeScriptCompile Include="math\GameMath.ts" />
|
||||
<TypeScriptCompile Include="gameobjects\DynamicTexture.ts" />
|
||||
<TypeScriptCompile Include="components\animation\AnimationManager.ts" />
|
||||
<Content Include="loader\Cache.js">
|
||||
<DependentUpon>Cache.ts</DependentUpon>
|
||||
</Content>
|
||||
|
||||
+27
-7
@@ -1,6 +1,6 @@
|
||||
/// <reference path="Phaser.ts" />
|
||||
/// <reference path="Game.ts" />
|
||||
/// <reference path="components/CSS3Filters.ts" />
|
||||
/// <reference path="display/CSS3Filters.ts" />
|
||||
/// <reference path="system/StageScaleMode.ts" />
|
||||
/// <reference path="system/screens/BootScreen.ts" />
|
||||
/// <reference path="system/screens/PauseScreen.ts" />
|
||||
@@ -53,7 +53,7 @@ module Phaser {
|
||||
|
||||
this.context = this.canvas.getContext('2d');
|
||||
|
||||
this.css3 = new Phaser.Components.CSS3Filters(this.canvas);
|
||||
this.css3 = new Phaser.Display.CSS3Filters(this.canvas);
|
||||
|
||||
this.scaleMode = StageScaleMode.NO_SCALE;
|
||||
this.scale = new StageScaleMode(this._game, width, height);
|
||||
@@ -102,9 +102,9 @@ module Phaser {
|
||||
|
||||
/**
|
||||
* Controls the CSS3 Filters applied to the Stages canvas object.
|
||||
* @type {Phaser.Components.CSS3Filters}
|
||||
* @type {Phaser.Display.CSS3Filters}
|
||||
*/
|
||||
public css3: Phaser.Components.CSS3Filters;
|
||||
public css3: Phaser.Display.CSS3Filters;
|
||||
|
||||
/**
|
||||
* Bound of this stage.
|
||||
@@ -175,6 +175,13 @@ 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
|
||||
*/
|
||||
@@ -196,10 +203,9 @@ module Phaser {
|
||||
|
||||
this.scale.update();
|
||||
|
||||
if (this.clear)
|
||||
if (this.clear || (this._game.paused && this.disablePauseScreen == false))
|
||||
{
|
||||
// A 'fix' for the horrendous Android stock browser bug: https://code.google.com/p/android/issues/detail?id=39247
|
||||
if (this._game.device.android && this._game.device.chrome == false)
|
||||
if (this.patchAndroidClearRectBug)
|
||||
{
|
||||
this.context.fillStyle = 'rgb(0,0,0)';
|
||||
this.context.fillRect(0, 0, this.width, this.height);
|
||||
@@ -295,6 +301,7 @@ module Phaser {
|
||||
}
|
||||
|
||||
this.saveCanvasValues();
|
||||
|
||||
this._game.paused = true;
|
||||
|
||||
}
|
||||
@@ -307,6 +314,7 @@ module Phaser {
|
||||
}
|
||||
|
||||
this.restoreCanvasValues();
|
||||
|
||||
this._game.paused = false;
|
||||
|
||||
}
|
||||
@@ -373,11 +381,23 @@ module Phaser {
|
||||
this.context.lineWidth = this.lineWidth;
|
||||
this.context.fillStyle = this.fillStyle;
|
||||
|
||||
if (this.patchAndroidClearRectBug)
|
||||
{
|
||||
this.context.fillStyle = 'rgb(0,0,0)';
|
||||
this.context.fillRect(0, 0, this.width, this.height);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.context.clearRect(0, 0, this.width, this.height);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public set backgroundColor(color: string) {
|
||||
|
||||
this.canvas.style.backgroundColor = color;
|
||||
this._backgroundColor = color;
|
||||
|
||||
}
|
||||
|
||||
public get backgroundColor(): string {
|
||||
|
||||
+2
-2
@@ -59,7 +59,7 @@ module Phaser {
|
||||
* Reference to the input manager
|
||||
* @type {Input}
|
||||
*/
|
||||
public input: Input;
|
||||
public input: InputManager;
|
||||
|
||||
/**
|
||||
* Reference to the assets loader.
|
||||
@@ -89,7 +89,7 @@ module Phaser {
|
||||
* Reference to game clock.
|
||||
* @type {Time}
|
||||
*/
|
||||
public time: Time;
|
||||
public time: TimeManager;
|
||||
|
||||
/**
|
||||
* Reference to the tween manager.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/// <reference path="../../Game.ts" />
|
||||
/// <reference path="../Game.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Animation
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
/// <reference path="../../Game.ts" />
|
||||
/// <reference path="../../gameobjects/Sprite.ts" />
|
||||
/// <reference path="../../loader/AnimationLoader.ts" />
|
||||
/// <reference path="../Game.ts" />
|
||||
/// <reference path="../gameobjects/Sprite.ts" />
|
||||
/// <reference path="../loader/AnimationLoader.ts" />
|
||||
/// <reference path="Animation.ts" />
|
||||
/// <reference path="Frame.ts" />
|
||||
/// <reference path="FrameData.ts" />
|
||||
@@ -1,4 +1,4 @@
|
||||
/// <reference path="../../Game.ts" />
|
||||
/// <reference path="../Game.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Frame
|
||||
@@ -1,4 +1,4 @@
|
||||
/// <reference path="../../Game.ts" />
|
||||
/// <reference path="../Game.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - FrameData
|
||||
+20
-18
@@ -2,10 +2,10 @@
|
||||
/// <reference path="../geom/Point.ts" />
|
||||
/// <reference path="../geom/Rectangle.ts" />
|
||||
/// <reference path="../math/Vec2.ts" />
|
||||
/// <reference path="../components/camera/CameraFX.ts" />
|
||||
/// <reference path="../components/Texture.ts" />
|
||||
/// <reference path="../components/Transform.ts" />
|
||||
/// <reference path="../display/Texture.ts" />
|
||||
/// <reference path="../gameobjects/TransformManager.ts" />
|
||||
/// <reference path="../gameobjects/Sprite.ts" />
|
||||
/// <reference path="../core/PluginManager.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Camera
|
||||
@@ -46,10 +46,10 @@ module Phaser {
|
||||
// The rect of the area being rendered in stage/screen coordinates
|
||||
this.screenView = new Rectangle(x, y, width, height);
|
||||
|
||||
this.fx = new CameraFX(this.game, this);
|
||||
this.plugins = new PluginManager(this.game, this);
|
||||
|
||||
this.transform = new Phaser.Components.Transform(this);
|
||||
this.texture = new Phaser.Components.Texture(this);
|
||||
this.transform = new Phaser.Components.TransformManager(this);
|
||||
this.texture = new Phaser.Display.Texture(this);
|
||||
|
||||
this.texture.opaque = false;
|
||||
|
||||
@@ -60,19 +60,25 @@ module Phaser {
|
||||
private _target: Sprite = null;
|
||||
|
||||
/**
|
||||
* Local private reference to Game.
|
||||
* Local reference to Game.
|
||||
*/
|
||||
public game: Game;
|
||||
|
||||
/**
|
||||
* The PluginManager for the Game
|
||||
* @type {PluginManager}
|
||||
*/
|
||||
public plugins: PluginManager;
|
||||
|
||||
/**
|
||||
* Optional texture used in the background of the Camera.
|
||||
*/
|
||||
public texture: Phaser.Components.Texture;
|
||||
public texture: Phaser.Display.Texture;
|
||||
|
||||
/**
|
||||
* The transform component.
|
||||
*/
|
||||
public transform: Phaser.Components.Transform;
|
||||
public transform: Phaser.Components.TransformManager;
|
||||
|
||||
/**
|
||||
* Camera "follow" style preset: camera has no deadzone, just tracks the focus object directly.
|
||||
@@ -154,12 +160,6 @@ module Phaser {
|
||||
*/
|
||||
public z: number = -1;
|
||||
|
||||
/**
|
||||
* Effects manager.
|
||||
* @type {CameraFX}
|
||||
*/
|
||||
public fx: CameraFX;
|
||||
|
||||
/**
|
||||
* Hides an object from this Camera. Hidden objects are not rendered.
|
||||
* The object must implement a public cameraBlacklist property.
|
||||
@@ -295,7 +295,7 @@ module Phaser {
|
||||
this.modified = true;
|
||||
}
|
||||
|
||||
this.fx.preUpdate();
|
||||
this.plugins.preUpdate();
|
||||
|
||||
if (this._target !== null)
|
||||
{
|
||||
@@ -364,6 +364,8 @@ module Phaser {
|
||||
}
|
||||
}
|
||||
|
||||
this.plugins.update();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -400,7 +402,7 @@ module Phaser {
|
||||
}
|
||||
}
|
||||
|
||||
this.fx.postUpdate();
|
||||
this.plugins.postUpdate();
|
||||
|
||||
}
|
||||
|
||||
@@ -431,7 +433,7 @@ module Phaser {
|
||||
public destroy() {
|
||||
|
||||
this.game.world.cameras.removeCamera(this.ID);
|
||||
this.fx.destroy();
|
||||
this.plugins.destroy();
|
||||
}
|
||||
|
||||
public get x(): number {
|
||||
|
||||
@@ -1,225 +0,0 @@
|
||||
/// <reference path="../../Game.ts" />
|
||||
/// <reference path="../../cameras/Camera.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - CameraFX
|
||||
*
|
||||
* CameraFX controls all special effects applied to game Cameras.
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class CameraFX {
|
||||
|
||||
constructor(game: Game, parent) {
|
||||
|
||||
this._game = game;
|
||||
this._parent = parent;
|
||||
this._fx = [];
|
||||
|
||||
this.active = true;
|
||||
this.visible = true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The essential reference to the main game object.
|
||||
*/
|
||||
private _game: Game;
|
||||
|
||||
/**
|
||||
* A reference to the object that owns this FXManager instance.
|
||||
*/
|
||||
private _parent;
|
||||
|
||||
/**
|
||||
* The array in which we keep all of the registered FX
|
||||
*/
|
||||
private _fx;
|
||||
|
||||
/**
|
||||
* Holds the size of the _fx array
|
||||
*/
|
||||
private _length: number;
|
||||
|
||||
/**
|
||||
* Controls whether any of the FX have preUpdate, update or postUpdate called
|
||||
*/
|
||||
public active: bool;
|
||||
|
||||
/**
|
||||
* Controls whether any of the FX have preRender, render or postRender called
|
||||
*/
|
||||
public visible: bool;
|
||||
|
||||
/**
|
||||
* Adds a new FX to the FXManager.
|
||||
* The effect must be an object with at least one of the following methods: preUpdate, postUpdate, preRender, render or postRender.
|
||||
* A new instance of the effect will be created and a reference to Game will be passed to the object constructor.
|
||||
* @param {object} effect
|
||||
* @return {any}
|
||||
*/
|
||||
public add(effect): any {
|
||||
|
||||
var result: bool = false;
|
||||
var newEffect = { effect: {}, preUpdate: false, postUpdate: false, preRender: false, render: false, postRender: false };
|
||||
|
||||
if (typeof effect === 'function')
|
||||
{
|
||||
newEffect.effect = new effect(this._game, this._parent);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Error("Invalid object given to Phaser.CameraFX.add");
|
||||
}
|
||||
|
||||
// Check for methods now to avoid having to do this every loop
|
||||
|
||||
if (typeof newEffect.effect['preUpdate'] === 'function')
|
||||
{
|
||||
newEffect.preUpdate = true;
|
||||
result = true;
|
||||
}
|
||||
|
||||
if (typeof newEffect.effect['postUpdate'] === 'function')
|
||||
{
|
||||
newEffect.postUpdate = true;
|
||||
result = true;
|
||||
}
|
||||
|
||||
if (typeof newEffect.effect['preRender'] === 'function')
|
||||
{
|
||||
newEffect.preRender = true;
|
||||
result = true;
|
||||
}
|
||||
|
||||
if (typeof newEffect.effect['render'] === 'function')
|
||||
{
|
||||
newEffect.render = true;
|
||||
result = true;
|
||||
}
|
||||
|
||||
if (typeof newEffect.effect['postRender'] === 'function')
|
||||
{
|
||||
newEffect.postRender = true;
|
||||
result = true;
|
||||
}
|
||||
|
||||
if (result == true)
|
||||
{
|
||||
this._length = this._fx.push(newEffect);
|
||||
|
||||
return newEffect.effect;
|
||||
}
|
||||
else
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Pre-update is called at the start of the objects update cycle, before any other updates have taken place.
|
||||
*/
|
||||
public preUpdate() {
|
||||
|
||||
if (this.active)
|
||||
{
|
||||
for (var i = 0; i < this._length; i++)
|
||||
{
|
||||
if (this._fx[i].preUpdate)
|
||||
{
|
||||
this._fx[i].effect.preUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Post-update is called at the end of the objects update cycle, after other update logic has taken place.
|
||||
*/
|
||||
public postUpdate() {
|
||||
|
||||
if (this.active)
|
||||
{
|
||||
for (var i = 0; i < this._length; i++)
|
||||
{
|
||||
if (this._fx[i].postUpdate)
|
||||
{
|
||||
this._fx[i].effect.postUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Pre-render is called at the start of the object render cycle, before any transforms have taken place.
|
||||
* It happens directly AFTER a canvas context.save has happened if added to a Camera.
|
||||
* @param {Camera} camera
|
||||
*/
|
||||
public preRender(camera:Camera) {
|
||||
|
||||
if (this.visible)
|
||||
{
|
||||
for (var i = 0; i < this._length; i++)
|
||||
{
|
||||
if (this._fx[i].preRender)
|
||||
{
|
||||
this._fx[i].effect.preRender(camera);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* render is called during the objects render cycle, right after all transforms have finished, but before any children/image data is rendered.
|
||||
* @param {Camera} camera
|
||||
*/
|
||||
public render(camera:Camera) {
|
||||
|
||||
if (this.visible)
|
||||
{
|
||||
for (var i = 0; i < this._length; i++)
|
||||
{
|
||||
if (this._fx[i].preRender)
|
||||
{
|
||||
this._fx[i].effect.preRender(camera);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Post-render is called during the objects render cycle, after the children/image data has been rendered.
|
||||
* It happens directly BEFORE a canvas context.restore has happened if added to a Camera.
|
||||
*/
|
||||
public postRender(camera:Camera) {
|
||||
|
||||
if (this.visible)
|
||||
{
|
||||
for (var i = 0; i < this._length; i++)
|
||||
{
|
||||
if (this._fx[i].postRender)
|
||||
{
|
||||
this._fx[i].effect.postRender(camera);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear down this FXManager and null out references
|
||||
*/
|
||||
public destroy() {
|
||||
this._game = null;
|
||||
this._fx = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
/**
|
||||
* Phaser - Components - Debug
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
module Phaser.Components {
|
||||
|
||||
export class Debug {
|
||||
|
||||
/**
|
||||
* Render bound of this sprite for debugging? (default to false)
|
||||
* @type {boolean}
|
||||
*/
|
||||
public renderDebug: bool = false;
|
||||
|
||||
/**
|
||||
* Color of the Sprite when no image is present. Format is a css color string.
|
||||
* @type {string}
|
||||
*/
|
||||
public fillColor: string = 'rgb(255,255,255)';
|
||||
|
||||
/**
|
||||
* Color of bound when render debug. (see renderDebug) Format is a css color string.
|
||||
* @type {string}
|
||||
*/
|
||||
public renderDebugColor: string = 'rgba(0,255,0,0.5)';
|
||||
|
||||
/**
|
||||
* Color of points when render debug. (see renderDebug) Format is a css color string.
|
||||
* @type {string}
|
||||
*/
|
||||
public renderDebugPointColor: string = 'rgba(255,255,255,1)';
|
||||
|
||||
/**
|
||||
* Renders the bounding box around this Sprite and the contact points. Useful for visually debugging.
|
||||
* @param camera {Camera} Camera the bound will be rendered to.
|
||||
* @param cameraOffsetX {number} X offset of bound to the camera.
|
||||
* @param cameraOffsetY {number} Y offset of bound to the camera.
|
||||
*/
|
||||
/*
|
||||
private renderBounds(camera: Camera, cameraOffsetX: number, cameraOffsetY: number) {
|
||||
|
||||
this._dx = cameraOffsetX + (this.frameBounds.topLeft.x - camera.worldView.x);
|
||||
this._dy = cameraOffsetY + (this.frameBounds.topLeft.y - camera.worldView.y);
|
||||
|
||||
this.context.fillStyle = this.renderDebugColor;
|
||||
this.context.fillRect(this._dx, this._dy, this.frameBounds.width, this.frameBounds.height);
|
||||
|
||||
//this.context.fillStyle = this.renderDebugPointColor;
|
||||
|
||||
//var hw = this.frameBounds.halfWidth * this.scale.x;
|
||||
//var hh = this.frameBounds.halfHeight * this.scale.y;
|
||||
//var sw = (this.frameBounds.width * this.scale.x) - 1;
|
||||
//var sh = (this.frameBounds.height * this.scale.y) - 1;
|
||||
|
||||
//this.context.fillRect(this._dx, this._dy, 1, 1); // top left
|
||||
//this.context.fillRect(this._dx + hw, this._dy, 1, 1); // top center
|
||||
//this.context.fillRect(this._dx + sw, this._dy, 1, 1); // top right
|
||||
//this.context.fillRect(this._dx, this._dy + hh, 1, 1); // left center
|
||||
//this.context.fillRect(this._dx + hw, this._dy + hh, 1, 1); // center
|
||||
//this.context.fillRect(this._dx + sw, this._dy + hh, 1, 1); // right center
|
||||
//this.context.fillRect(this._dx, this._dy + sh, 1, 1); // bottom left
|
||||
//this.context.fillRect(this._dx + hw, this._dy + sh, 1, 1); // bottom center
|
||||
//this.context.fillRect(this._dx + sw, this._dy + sh, 1, 1); // bottom right
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
/// <reference path="../Game.ts" />
|
||||
/// <reference path="../Statics.ts" />
|
||||
/// <reference path="../components/Texture.ts" />
|
||||
/// <reference path="../components/Transform.ts" />
|
||||
/// <reference path="../display/Texture.ts" />
|
||||
/// <reference path="../gameobjects/TransformManager.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Group
|
||||
@@ -29,8 +29,8 @@ module Phaser {
|
||||
|
||||
this.ID = this.game.world.getNextGroupID();
|
||||
|
||||
this.transform = new Phaser.Components.Transform(this);
|
||||
this.texture = new Phaser.Components.Texture(this);
|
||||
this.transform = new Phaser.Components.TransformManager(this);
|
||||
this.texture = new Phaser.Display.Texture(this);
|
||||
this.texture.opaque = false;
|
||||
|
||||
}
|
||||
@@ -98,12 +98,12 @@ module Phaser {
|
||||
/**
|
||||
* Optional texture used in the background of the Camera.
|
||||
*/
|
||||
public texture: Phaser.Components.Texture;
|
||||
public texture: Phaser.Display.Texture;
|
||||
|
||||
/**
|
||||
* The transform component.
|
||||
*/
|
||||
public transform: Phaser.Components.Transform;
|
||||
public transform: Phaser.Components.TransformManager;
|
||||
|
||||
/**
|
||||
* A boolean representing if the Group has been modified in any way via a scale, rotate, flip or skew.
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
/// <reference path="../Game.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Plugin
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class Plugin {
|
||||
|
||||
constructor(game: Phaser.Game, parent) {
|
||||
|
||||
this.game = game;
|
||||
this.parent = parent;
|
||||
|
||||
this.active = false;
|
||||
this.visible = false;
|
||||
|
||||
this.hasPreUpdate = false;
|
||||
this.hasUpdate = false;
|
||||
this.hasPostUpdate = false;
|
||||
|
||||
this.hasPreRender = false;
|
||||
this.hasRender = false;
|
||||
this.hasPostRender = false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Local reference to Game.
|
||||
*/
|
||||
public game: Game;
|
||||
|
||||
/**
|
||||
* The object that owns this Plugin (i.e. Camera, Game, Stage, etc).
|
||||
*/
|
||||
public parent;
|
||||
|
||||
/**
|
||||
* Controls whether preUpdate, update or postUpdate are called
|
||||
*/
|
||||
public active: bool;
|
||||
|
||||
/**
|
||||
* Controls whether preRender, render or postRender are called
|
||||
*/
|
||||
public visible: bool;
|
||||
|
||||
/**
|
||||
* Quick access booleans to avoid having to do a function existence check during tight inner loops
|
||||
*/
|
||||
public hasPreUpdate: bool;
|
||||
public hasUpdate: bool;
|
||||
public hasPostUpdate: bool;
|
||||
|
||||
public hasPreRender: bool;
|
||||
public hasRender: bool;
|
||||
public hasPostRender: bool;
|
||||
|
||||
/**
|
||||
* Pre-update is called at the start of the update cycle, before any other updates have taken place.
|
||||
* It is only called if active is set to true.
|
||||
*/
|
||||
public preUpdate() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Pre-update is called at the start of the update cycle, before any other updates have taken place.
|
||||
* It is only called if active is set to true.
|
||||
*/
|
||||
public update() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Post-update is called at the end of the objects update cycle, after other update logic has taken place.
|
||||
* It is only called if active is set to true.
|
||||
*/
|
||||
public postUpdate() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Pre-render is called right before the Game Renderer starts and before any custom preRender callbacks have been run.
|
||||
* It is only called if visible is set to true.
|
||||
*/
|
||||
public preRender() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Pre-render is called right before the Game Renderer starts and before any custom preRender callbacks have been run.
|
||||
* It is only called if visible is set to true.
|
||||
*/
|
||||
public render() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Post-render is called after every camera and game object has been rendered, also after any custom postRender callbacks have been run.
|
||||
* It is only called if visible is set to true.
|
||||
*/
|
||||
public postRender() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear down this Plugin and null out references
|
||||
*/
|
||||
public destroy() {
|
||||
|
||||
this.game = null;
|
||||
this.parent = null;
|
||||
|
||||
this.active = false;
|
||||
this.visible = false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,222 @@
|
||||
/// <reference path="../Game.ts" />
|
||||
/// <reference path="Plugin.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - PluginManager
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class PluginManager {
|
||||
|
||||
constructor(game:Game, parent) {
|
||||
|
||||
this.game = game;
|
||||
|
||||
this._parent = parent;
|
||||
|
||||
this.plugins = [];
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Local reference to Game.
|
||||
*/
|
||||
public game: Game;
|
||||
|
||||
/**
|
||||
* The object that owns this PluginManager.
|
||||
*/
|
||||
private _parent;
|
||||
|
||||
/**
|
||||
* Plugin loop pointer
|
||||
* @type {number}
|
||||
*/
|
||||
private _p: number;
|
||||
|
||||
/**
|
||||
* Plugins array counter
|
||||
* @type {number}
|
||||
*/
|
||||
private _pluginsLength: number;
|
||||
|
||||
/**
|
||||
* An Array of Plugins
|
||||
* @type {Array}
|
||||
*/
|
||||
public plugins: Phaser.Plugin[];
|
||||
|
||||
/**
|
||||
* Add a new Plugin to the PluginManager.
|
||||
* The plugins game and parent reference are set to this game and pluginmanager parent.
|
||||
* @type {Phaser.Plugin}
|
||||
*/
|
||||
public add(plugin):any {
|
||||
|
||||
var result: bool = false;
|
||||
|
||||
// Prototype?
|
||||
if (typeof plugin === 'function')
|
||||
{
|
||||
plugin = new plugin(this.game, this._parent);
|
||||
}
|
||||
else
|
||||
{
|
||||
plugin.game = this.game;
|
||||
plugin.parent = this._parent;
|
||||
}
|
||||
|
||||
// Check for methods now to avoid having to do this every loop
|
||||
|
||||
if (typeof plugin['preUpdate'] === 'function')
|
||||
{
|
||||
plugin.hasPreUpdate = true;
|
||||
result = true;
|
||||
}
|
||||
|
||||
if (typeof plugin['update'] === 'function')
|
||||
{
|
||||
plugin.hasUpdate = true;
|
||||
result = true;
|
||||
}
|
||||
|
||||
if (typeof plugin['postUpdate'] === 'function')
|
||||
{
|
||||
plugin.hasPostUpdate = true;
|
||||
result = true;
|
||||
}
|
||||
|
||||
if (typeof plugin['preRender'] === 'function')
|
||||
{
|
||||
plugin.hasPreRender = true;
|
||||
result = true;
|
||||
}
|
||||
|
||||
if (typeof plugin['render'] === 'function')
|
||||
{
|
||||
plugin.hasRender = true;
|
||||
result = true;
|
||||
}
|
||||
|
||||
if (typeof plugin['postRender'] === 'function')
|
||||
{
|
||||
plugin.hasPostRender = true;
|
||||
result = true;
|
||||
}
|
||||
|
||||
// The plugin must have at least one of the above functions to be added to the PluginManager.
|
||||
if (result == true)
|
||||
{
|
||||
if (plugin.hasPreUpdate || plugin.hasUpdate || plugin.hasPostUpdate)
|
||||
{
|
||||
plugin.active = true;
|
||||
}
|
||||
|
||||
if (plugin.hasPreRender || plugin.hasRender || plugin.hasPostRender)
|
||||
{
|
||||
plugin.visible = true;
|
||||
}
|
||||
|
||||
this._pluginsLength = this.plugins.push(plugin);
|
||||
|
||||
return plugin;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public remove(plugin) {
|
||||
|
||||
// TODO :)
|
||||
this._pluginsLength--;
|
||||
|
||||
}
|
||||
|
||||
public preUpdate() {
|
||||
|
||||
for (this._p = 0; this._p < this._pluginsLength; this._p++)
|
||||
{
|
||||
if (this.plugins[this._p].active && this.plugins[this._p].hasPreUpdate)
|
||||
{
|
||||
this.plugins[this._p].preUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public update() {
|
||||
|
||||
for (this._p = 0; this._p < this._pluginsLength; this._p++)
|
||||
{
|
||||
if (this.plugins[this._p].active && this.plugins[this._p].hasUpdate)
|
||||
{
|
||||
this.plugins[this._p].update();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public postUpdate() {
|
||||
|
||||
for (this._p = 0; this._p < this._pluginsLength; this._p++)
|
||||
{
|
||||
if (this.plugins[this._p].active && this.plugins[this._p].hasPostUpdate)
|
||||
{
|
||||
this.plugins[this._p].postUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public preRender() {
|
||||
|
||||
for (this._p = 0; this._p < this._pluginsLength; this._p++)
|
||||
{
|
||||
if (this.plugins[this._p].visible && this.plugins[this._p].hasPreRender)
|
||||
{
|
||||
this.plugins[this._p].preRender();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public render() {
|
||||
|
||||
for (this._p = 0; this._p < this._pluginsLength; this._p++)
|
||||
{
|
||||
if (this.plugins[this._p].visible && this.plugins[this._p].hasRender)
|
||||
{
|
||||
this.plugins[this._p].render();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public postRender() {
|
||||
|
||||
for (this._p = 0; this._p < this._pluginsLength; this._p++)
|
||||
{
|
||||
if (this.plugins[this._p].visible && this.plugins[this._p].hasPostRender)
|
||||
{
|
||||
this.plugins[this._p].postRender();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public destroy() {
|
||||
|
||||
this.plugins.length = 0;
|
||||
this._pluginsLength = 0;
|
||||
this.game = null;
|
||||
this._parent = null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
/// <reference path="../Game.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Components - CSS3Filters
|
||||
* Phaser - Display - CSS3Filters
|
||||
*
|
||||
* Allows for easy addition and modification of CSS3 Filters on DOM objects (typically the Game.Stage.canvas).
|
||||
*/
|
||||
|
||||
module Phaser.Components {
|
||||
module Phaser.Display {
|
||||
|
||||
export class CSS3Filters {
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
/// <reference path="../Game.ts" />
|
||||
/// <reference path="../utils/RectangleUtils.ts" />
|
||||
/// <reference path="../utils/ColorUtils.ts" />
|
||||
/// <reference path="IGameObject.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - DynamicTexture
|
||||
* Phaser - Display - DynamicTexture
|
||||
*
|
||||
* A DynamicTexture can be thought of as a mini canvas into which you can draw anything.
|
||||
* Game Objects can be assigned a DynamicTexture, so when they render in the world they do so
|
||||
@@ -34,7 +33,7 @@ module Phaser {
|
||||
this.canvas.height = height;
|
||||
this.context = this.canvas.getContext('2d');
|
||||
|
||||
this.css3 = new Phaser.Components.CSS3Filters(this.canvas);
|
||||
this.css3 = new Phaser.Display.CSS3Filters(this.canvas);
|
||||
|
||||
this.bounds = new Rectangle(0, 0, width, height);
|
||||
|
||||
@@ -66,7 +65,7 @@ module Phaser {
|
||||
* Only really useful if you attach this canvas to the DOM.
|
||||
* @type {Phaser.Components.CSS3Filters}
|
||||
*/
|
||||
public css3: Phaser.Components.CSS3Filters;
|
||||
public css3: Phaser.Display.CSS3Filters;
|
||||
|
||||
/**
|
||||
* Bound of this texture with width and height info.
|
||||
@@ -1,14 +1,14 @@
|
||||
/// <reference path="../Game.ts" />
|
||||
/// <reference path="../gameobjects/DynamicTexture.ts" />
|
||||
/// <reference path="../utils/SpriteUtils.ts" />
|
||||
/// <reference path="DynamicTexture.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Components - Texture
|
||||
* Phaser - Display - Texture
|
||||
*
|
||||
* The Texture being used to render the object (Sprite, Group background, etc). Either Image based on a DynamicTexture.
|
||||
*/
|
||||
|
||||
module Phaser.Components {
|
||||
module Phaser.Display {
|
||||
|
||||
export class Texture {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/// <reference path="../../Game.ts" />
|
||||
/// <reference path="../Game.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Components - Events
|
||||
@@ -6,7 +6,7 @@
|
||||
* Signals that are dispatched by the Sprite and its various components
|
||||
*/
|
||||
|
||||
module Phaser.Components.Sprite {
|
||||
module Phaser.Components {
|
||||
|
||||
export class Events {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/// <reference path="../Game.ts" />
|
||||
/// <reference path="../tweens/Tween.ts" />
|
||||
/// <reference path="../gameobjects/Emitter.ts" />
|
||||
/// <reference path="../gameobjects/Particle.ts" />
|
||||
/// <reference path="../particles/ArcadeEmitter.ts" />
|
||||
/// <reference path="../particles/ArcadeParticle.ts" />
|
||||
/// <reference path="../gameobjects/Sprite.ts" />
|
||||
/// <reference path="../gameobjects/Button.ts" />
|
||||
/// <reference path="../ui/Button.ts" />
|
||||
/// <reference path="../gameobjects/ScrollZone.ts" />
|
||||
/// <reference path="../gameobjects/DynamicTexture.ts" />
|
||||
/// <reference path="../gameobjects/Tilemap.ts" />
|
||||
/// <reference path="../display/DynamicTexture.ts" />
|
||||
/// <reference path="../tilemap/Tilemap.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - GameObjectFactory
|
||||
@@ -76,8 +76,8 @@ module Phaser {
|
||||
* @param [downFrame] {string|number} This is the frame or frameName that will be set when this button is in a down state. Give either a number to use a frame ID or a string for a frame name.
|
||||
* @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): Button {
|
||||
return <Button> this._world.group.add(new Button(this._game, x, y, key, callback, callbackContext, overFrame, outFrame, downFrame));
|
||||
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));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -139,8 +139,8 @@ module Phaser {
|
||||
*
|
||||
* @return {Particle} The newly created particle object.
|
||||
*/
|
||||
public particle(): Particle {
|
||||
return new Particle(this._game);
|
||||
public particle(): ArcadeParticle {
|
||||
return new ArcadeParticle(this._game);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -151,8 +151,8 @@ module Phaser {
|
||||
* @param size {number} Optional, size of this emitter.
|
||||
* @return {Emitter} The newly created emitter object.
|
||||
*/
|
||||
public emitter(x?: number = 0, y?: number = 0, size?: number = 0): Emitter {
|
||||
return <Emitter> this._world.group.add(new Emitter(this._game, x, y, size));
|
||||
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));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -224,7 +224,7 @@ module Phaser {
|
||||
* @param button The Button to add to the Game World
|
||||
* @return {Phaser.Button} The Button object
|
||||
*/
|
||||
public existingButton(button: Button): Button {
|
||||
public existingButton(button: UI.Button): UI.Button {
|
||||
return this._world.group.add(button);
|
||||
}
|
||||
|
||||
@@ -246,7 +246,7 @@ module Phaser {
|
||||
* @param emitter The Emitter to add to the Game World
|
||||
* @return {Phaser.Emitter} The Emitter object
|
||||
*/
|
||||
public existingEmitter(emitter: Emitter): Emitter {
|
||||
public existingEmitter(emitter: ArcadeEmitter): ArcadeEmitter {
|
||||
return this._world.group.add(emitter);
|
||||
}
|
||||
|
||||
|
||||
@@ -72,12 +72,12 @@ module Phaser {
|
||||
/**
|
||||
* The texture used to render.
|
||||
*/
|
||||
texture: Phaser.Components.Texture;
|
||||
texture: Phaser.Display.Texture;
|
||||
|
||||
/**
|
||||
* The transform component.
|
||||
*/
|
||||
transform: Phaser.Components.Transform;
|
||||
transform: Phaser.Components.TransformManager;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/// <reference path="../Game.ts" />
|
||||
/// <reference path="../geom/Rectangle.ts" />
|
||||
/// <reference path="../components/ScrollRegion.ts" />
|
||||
/// <reference path="ScrollRegion.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - ScrollZone
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/// <reference path="../Game.ts" />
|
||||
/// <reference path="../math/Vec2.ts" />
|
||||
/// <reference path="../geom/Rectangle.ts" />
|
||||
/// <reference path="../components/animation/AnimationManager.ts" />
|
||||
/// <reference path="../components/Texture.ts" />
|
||||
/// <reference path="../components/Transform.ts" />
|
||||
/// <reference path="../components/sprite/Input.ts" />
|
||||
/// <reference path="../components/sprite/Events.ts" />
|
||||
/// <reference path="../animation/AnimationManager.ts" />
|
||||
/// <reference path="../input/InputHandler.ts" />
|
||||
/// <reference path="../display/Texture.ts" />
|
||||
/// <reference path="TransformManager.ts" />
|
||||
/// <reference path="Events.ts" />
|
||||
/// <reference path="../physics/arcade/Body.ts" />
|
||||
|
||||
/**
|
||||
@@ -42,11 +42,11 @@ module Phaser {
|
||||
this.group = null;
|
||||
this.name = '';
|
||||
|
||||
this.events = new Phaser.Components.Sprite.Events(this);
|
||||
this.events = new Phaser.Components.Events(this);
|
||||
this.animations = new Phaser.Components.AnimationManager(this);
|
||||
this.input = new Phaser.Components.Sprite.Input(this);
|
||||
this.texture = new Phaser.Components.Texture(this);
|
||||
this.transform = new Phaser.Components.Transform(this);
|
||||
this.input = new Phaser.Components.InputHandler(this);
|
||||
this.texture = new Phaser.Display.Texture(this);
|
||||
this.transform = new Phaser.Components.TransformManager(this);
|
||||
|
||||
if (key !== null)
|
||||
{
|
||||
@@ -151,25 +151,25 @@ module Phaser {
|
||||
/**
|
||||
* The texture used to render the Sprite.
|
||||
*/
|
||||
public texture: Phaser.Components.Texture;
|
||||
public texture: Phaser.Display.Texture;
|
||||
|
||||
/**
|
||||
* The Sprite transform component.
|
||||
*/
|
||||
public transform: Phaser.Components.Transform;
|
||||
public transform: Phaser.Components.TransformManager;
|
||||
|
||||
/**
|
||||
* The Input component
|
||||
*/
|
||||
public input: Phaser.Components.Sprite.Input;
|
||||
public input: Phaser.Components.InputHandler;
|
||||
|
||||
/**
|
||||
* The Events component
|
||||
*/
|
||||
public events: Phaser.Components.Sprite.Events;
|
||||
public events: Phaser.Components.Events;
|
||||
|
||||
/**
|
||||
* This manages animations of the sprite. You can modify animations though it. (see AnimationManager)
|
||||
* This manages animations of the sprite. You can modify animations through it. (see AnimationManager)
|
||||
* @type AnimationManager
|
||||
*/
|
||||
public animations: Phaser.Components.AnimationManager;
|
||||
@@ -359,6 +359,17 @@ module Phaser {
|
||||
|
||||
this.animations.update();
|
||||
|
||||
this.checkBounds();
|
||||
|
||||
if (this.modified == true && this.transform.scale.equals(1) && this.transform.skew.equals(0) && this.transform.rotation == 0 && this.transform.rotationOffset == 0 && this.texture.flippedX == false && this.texture.flippedY == false)
|
||||
{
|
||||
this.modified = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private checkBounds() {
|
||||
|
||||
if (Phaser.RectangleUtils.intersects(this.worldView, this.game.world.bounds))
|
||||
{
|
||||
this.outOfBounds = false;
|
||||
@@ -382,11 +393,6 @@ module Phaser {
|
||||
}
|
||||
}
|
||||
|
||||
if (this.modified == true && this.transform.scale.equals(1) && this.transform.skew.equals(0) && this.transform.rotation == 0 && this.transform.rotationOffset == 0 && this.texture.flippedX == false && this.texture.flippedY == false)
|
||||
{
|
||||
this.modified = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,15 +3,15 @@
|
||||
/// <reference path="../geom/Point.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Components - Transform
|
||||
* Phaser - Components - TransformManager
|
||||
*/
|
||||
|
||||
module Phaser.Components {
|
||||
|
||||
export class Transform {
|
||||
export class TransformManager {
|
||||
|
||||
/**
|
||||
* Creates a new Transform component
|
||||
* Creates a new TransformManager component
|
||||
* @param parent The game object using this transform
|
||||
*/
|
||||
constructor(parent) {
|
||||
@@ -58,6 +58,49 @@ module Phaser.Components {
|
||||
private _distance: number;
|
||||
private _prevRotation: number;
|
||||
|
||||
/**
|
||||
* Reference to Phaser.Game
|
||||
*/
|
||||
public game: Game;
|
||||
|
||||
/**
|
||||
* Reference to the parent object (Sprite, Group, etc)
|
||||
*/
|
||||
public parent: Phaser.Sprite;
|
||||
|
||||
/**
|
||||
* Scale of the object. A scale of 1.0 is the original size. 0.5 half size. 2.0 double sized.
|
||||
*/
|
||||
public scale: Vec2;
|
||||
|
||||
/**
|
||||
* Skew the object along the x and y axis. A skew value of 0 is no skew.
|
||||
*/
|
||||
public skew: Vec2;
|
||||
|
||||
/**
|
||||
* The influence of camera movement upon the object, if supported.
|
||||
*/
|
||||
public scrollFactor: Vec2;
|
||||
|
||||
/**
|
||||
* The origin is the point around which scale and rotation takes place and defaults to the top-left of the sprite.
|
||||
*/
|
||||
public origin: Vec2;
|
||||
|
||||
/**
|
||||
* This value is added to the rotation of the object.
|
||||
* For example if you had a texture drawn facing straight up then you could set
|
||||
* rotationOffset to 90 and it would correspond correctly with Phasers right-handed coordinate system.
|
||||
* @type {number}
|
||||
*/
|
||||
public rotationOffset: number = 0;
|
||||
|
||||
/**
|
||||
* The rotation of the object in degrees. Phaser uses a right-handed coordinate system, where 0 points to the right.
|
||||
*/
|
||||
public rotation: number = 0;
|
||||
|
||||
/**
|
||||
* The center of the Sprite in world coordinates, after taking scaling and rotation into consideration
|
||||
*/
|
||||
@@ -88,6 +131,62 @@ module Phaser.Components {
|
||||
*/
|
||||
public local: Mat3;
|
||||
|
||||
/**
|
||||
* The distance from the center of the transform to the rotation origin.
|
||||
*/
|
||||
public get distance(): number {
|
||||
return this._distance;
|
||||
}
|
||||
|
||||
/**
|
||||
* The angle between the center of the transform to the rotation origin.
|
||||
*/
|
||||
public get angleToCenter(): number {
|
||||
return this._angle;
|
||||
}
|
||||
|
||||
/**
|
||||
* The offset on the X axis of the origin
|
||||
*/
|
||||
public get offsetX(): number {
|
||||
return this._offset.x;
|
||||
}
|
||||
|
||||
/**
|
||||
* The offset on the Y axis of the origin
|
||||
*/
|
||||
public get offsetY(): number {
|
||||
return this._offset.y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Half the width of the parent sprite, taking into consideration scaling
|
||||
*/
|
||||
public get halfWidth(): number {
|
||||
return this._halfSize.x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Half the height of the parent sprite, taking into consideration scaling
|
||||
*/
|
||||
public get halfHeight(): number {
|
||||
return this._halfSize.y;
|
||||
}
|
||||
|
||||
/**
|
||||
* The equivalent of Math.sin(rotation + rotationOffset)
|
||||
*/
|
||||
public get sin(): number {
|
||||
return this._sc.x;
|
||||
}
|
||||
|
||||
/**
|
||||
* The equivalent of Math.cos(rotation + rotationOffset)
|
||||
*/
|
||||
public get cos(): number {
|
||||
return this._sc.y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates the transform cache. Called by the parent object on creation.
|
||||
*/
|
||||
@@ -228,105 +327,6 @@ module Phaser.Components {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Reference to Phaser.Game
|
||||
*/
|
||||
public game: Game;
|
||||
|
||||
/**
|
||||
* Reference to the parent object (Sprite, Group, etc)
|
||||
*/
|
||||
public parent: Phaser.Sprite;
|
||||
|
||||
/**
|
||||
* Scale of the object. A scale of 1.0 is the original size. 0.5 half size. 2.0 double sized.
|
||||
*/
|
||||
public scale: Vec2;
|
||||
|
||||
/**
|
||||
* Skew the object along the x and y axis. A skew value of 0 is no skew.
|
||||
*/
|
||||
public skew: Vec2;
|
||||
|
||||
/**
|
||||
* The influence of camera movement upon the object, if supported.
|
||||
*/
|
||||
public scrollFactor: Vec2;
|
||||
|
||||
/**
|
||||
* The origin is the point around which scale and rotation takes place and defaults to the top-left of the sprite.
|
||||
*/
|
||||
public origin: Vec2;
|
||||
|
||||
/**
|
||||
* This value is added to the rotation of the object.
|
||||
* For example if you had a texture drawn facing straight up then you could set
|
||||
* rotationOffset to 90 and it would correspond correctly with Phasers right-handed coordinate system.
|
||||
* @type {number}
|
||||
*/
|
||||
public rotationOffset: number = 0;
|
||||
|
||||
/**
|
||||
* The rotation of the object in degrees. Phaser uses a right-handed coordinate system, where 0 points to the right.
|
||||
*/
|
||||
public rotation: number = 0;
|
||||
|
||||
/**
|
||||
* The distance from the center of the transform to the rotation origin.
|
||||
*/
|
||||
public get distance(): number {
|
||||
return this._distance;
|
||||
}
|
||||
|
||||
/**
|
||||
* The angle between the center of the transform to the rotation origin.
|
||||
*/
|
||||
public get angleToCenter(): number {
|
||||
return this._angle;
|
||||
}
|
||||
|
||||
/**
|
||||
* The offset on the X axis of the origin
|
||||
*/
|
||||
public get offsetX(): number {
|
||||
return this._offset.x;
|
||||
}
|
||||
|
||||
/**
|
||||
* The offset on the Y axis of the origin
|
||||
*/
|
||||
public get offsetY(): number {
|
||||
return this._offset.y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Half the width of the parent sprite, taking into consideration scaling
|
||||
*/
|
||||
public get halfWidth(): number {
|
||||
return this._halfSize.x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Half the height of the parent sprite, taking into consideration scaling
|
||||
*/
|
||||
public get halfHeight(): number {
|
||||
return this._halfSize.y;
|
||||
}
|
||||
|
||||
/**
|
||||
* The equivalent of Math.sin(rotation + rotationOffset)
|
||||
*/
|
||||
public get sin(): number {
|
||||
return this._sc.x;
|
||||
}
|
||||
|
||||
/**
|
||||
* The equivalent of Math.cos(rotation + rotationOffset)
|
||||
*/
|
||||
public get cos(): number {
|
||||
return this._sc.y;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,999 +0,0 @@
|
||||
/// <reference path="../Game.ts" />
|
||||
/// <reference path="../core/Signal.ts" />
|
||||
/// <reference path="../utils/PointUtils.ts" />
|
||||
/// <reference path="../math/Vec2Utils.ts" />
|
||||
/// <reference path="Pointer.ts" />
|
||||
/// <reference path="MSPointer.ts" />
|
||||
/// <reference path="Gestures.ts" />
|
||||
/// <reference path="Mouse.ts" />
|
||||
/// <reference path="Keyboard.ts" />
|
||||
/// <reference path="Touch.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Input
|
||||
*
|
||||
* A game specific Input manager that looks after the mouse, keyboard and touch objects.
|
||||
* This is updated by the core game loop.
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class Input {
|
||||
|
||||
constructor(game: Game) {
|
||||
|
||||
this.game = game;
|
||||
|
||||
this.mousePointer = new Pointer(this.game, 0);
|
||||
this.pointer1 = new Pointer(this.game, 1);
|
||||
this.pointer2 = new Pointer(this.game, 2);
|
||||
this.pointer3 = new Pointer(this.game, 3);
|
||||
this.pointer4 = new Pointer(this.game, 4);
|
||||
this.pointer5 = new Pointer(this.game, 5);
|
||||
|
||||
this.mouse = new Mouse(this.game);
|
||||
this.keyboard = new Keyboard(this.game);
|
||||
this.touch = new Touch(this.game);
|
||||
this.mspointer = new MSPointer(this.game);
|
||||
this.gestures = new Gestures(this.game);
|
||||
|
||||
this.onDown = new Phaser.Signal();
|
||||
this.onUp = new Phaser.Signal();
|
||||
this.onTap = new Phaser.Signal();
|
||||
this.onHold = new Phaser.Signal();
|
||||
|
||||
this.scale = new Vec2(1, 1);
|
||||
this.speed = new Vec2;
|
||||
this.position = new Vec2;
|
||||
this._oldPosition = new Vec2;
|
||||
this.circle = new Circle(0, 0, 44);
|
||||
|
||||
this.camera = this.game.camera;
|
||||
|
||||
this.activePointer = this.mousePointer;
|
||||
this.currentPointers = 0;
|
||||
|
||||
this.hitCanvas = <HTMLCanvasElement> document.createElement('canvas');
|
||||
this.hitCanvas.width = 1;
|
||||
this.hitCanvas.height = 1;
|
||||
this.hitContext = this.hitCanvas.getContext('2d');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Local reference to game.
|
||||
*/
|
||||
public game: Game;
|
||||
|
||||
/**
|
||||
* A 1x1 sized canvas used for pixel-perfect checks
|
||||
* @type {HTMLCanvasElement}
|
||||
*/
|
||||
public hitCanvas: HTMLCanvasElement;
|
||||
|
||||
/**
|
||||
* The context of the 1x1 pixel check canvas
|
||||
* @type {CanvasRenderingContext2D}
|
||||
*/
|
||||
public hitContext: CanvasRenderingContext2D;
|
||||
|
||||
/**
|
||||
* A vector object representing the previous position of the Pointer.
|
||||
* @property vector
|
||||
* @type {Vec2}
|
||||
**/
|
||||
private _oldPosition: Vec2 = null;
|
||||
|
||||
/**
|
||||
* X coordinate of the most recent Pointer event
|
||||
* @type {Number}
|
||||
* @private
|
||||
*/
|
||||
private _x: number = 0;
|
||||
|
||||
/**
|
||||
* X coordinate of the most recent Pointer event
|
||||
* @type {Number}
|
||||
* @private
|
||||
*/
|
||||
private _y: number = 0;
|
||||
|
||||
/**
|
||||
* You can disable all Input by setting Input.disabled = true. While set all new input related events will be ignored.
|
||||
* If you need to disable just one type of input, for example mouse, use Input.mouse.disabled = true instead
|
||||
* @type {Boolean}
|
||||
*/
|
||||
public disabled: bool = false;
|
||||
|
||||
/**
|
||||
* Controls the expected behaviour when using a mouse and touch together on a multi-input device
|
||||
*/
|
||||
public multiInputOverride: number = Input.MOUSE_TOUCH_COMBINE;
|
||||
|
||||
/**
|
||||
* Static defining the behaviour expected on a multi-input device system.
|
||||
* With this setting when the mouse is used it updates the Input.x/y globals regardless if another pointer is active or not
|
||||
*/
|
||||
public static MOUSE_OVERRIDES_TOUCH: number = 0;
|
||||
|
||||
/**
|
||||
* Static defining the behaviour expected on a multi-input device system.
|
||||
* With this setting when the mouse is used it only updates the Input.x/y globals if no other pointer is active
|
||||
*/
|
||||
public static TOUCH_OVERRIDES_MOUSE: number = 1;
|
||||
|
||||
/**
|
||||
* Static defining the behaviour expected on a multi-input device system.
|
||||
* With this setting when the mouse is used it updates the Input.x/y globals at the same time as any active Pointer objects might
|
||||
*/
|
||||
public static MOUSE_TOUCH_COMBINE: number = 2;
|
||||
|
||||
/**
|
||||
* The camera being used for mouse and touch based pointers to calculate their world coordinates.
|
||||
* @property camera
|
||||
* @type {Camera}
|
||||
**/
|
||||
public camera: Camera;
|
||||
|
||||
/**
|
||||
* Phaser.Mouse handler
|
||||
* @type {Mouse}
|
||||
*/
|
||||
public mouse: Mouse;
|
||||
|
||||
/**
|
||||
* Phaser.Keyboard handler
|
||||
* @type {Keyboard}
|
||||
*/
|
||||
public keyboard: Keyboard;
|
||||
|
||||
/**
|
||||
* Phaser.Touch handler
|
||||
* @type {Touch}
|
||||
*/
|
||||
public touch: Touch;
|
||||
|
||||
/**
|
||||
* Phaser.MSPointer handler
|
||||
* @type {MSPointer}
|
||||
*/
|
||||
public mspointer: MSPointer;
|
||||
|
||||
/**
|
||||
* Phaser.Gestures handler
|
||||
* @type {Gestures}
|
||||
*/
|
||||
public gestures: Gestures;
|
||||
|
||||
/**
|
||||
* A vector object representing the current position of the Pointer.
|
||||
* @property vector
|
||||
* @type {Vec2}
|
||||
**/
|
||||
public position: Vec2 = null;
|
||||
|
||||
/**
|
||||
* A vector object representing the speed of the Pointer. Only really useful in single Pointer games,
|
||||
* otherwise see the Pointer objects directly.
|
||||
* @property vector
|
||||
* @type {Vec2}
|
||||
**/
|
||||
public speed: Vec2 = null;
|
||||
|
||||
/**
|
||||
* A Circle object centered on the x/y screen coordinates of the Input.
|
||||
* Default size of 44px (Apples recommended "finger tip" size) but can be changed to anything
|
||||
* @property circle
|
||||
* @type {Circle}
|
||||
**/
|
||||
public circle: Circle = null;
|
||||
|
||||
/**
|
||||
* The scale by which all input coordinates are multiplied, calculated by the StageScaleMode.
|
||||
* In an un-scaled game the values will be x: 1 and y: 1.
|
||||
* @type {Vec2}
|
||||
*/
|
||||
public scale: Vec2 = null;
|
||||
|
||||
/**
|
||||
* The maximum number of Pointers allowed to be active at any one time.
|
||||
* For lots of games it's useful to set this to 1
|
||||
* @type {Number}
|
||||
*/
|
||||
public maxPointers: number = 10;
|
||||
|
||||
/**
|
||||
* The current number of active Pointers.
|
||||
* @type {Number}
|
||||
*/
|
||||
public currentPointers: number = 0;
|
||||
|
||||
/**
|
||||
* A Signal dispatched when a mouse/Pointer object is pressed
|
||||
* @type {Phaser.Signal}
|
||||
*/
|
||||
public onDown: Phaser.Signal;
|
||||
|
||||
/**
|
||||
* A Signal dispatched when a mouse/Pointer object is released
|
||||
* @type {Phaser.Signal}
|
||||
*/
|
||||
public onUp: Phaser.Signal;
|
||||
|
||||
/**
|
||||
* A Signal dispatched when a Pointer object (including the mouse) is tapped: pressed and released quickly.
|
||||
* The signal sends 2 parameters. The Pointer that caused it and a boolean depending if the tap was a single tap or a double tap.
|
||||
* @type {Phaser.Signal}
|
||||
*/
|
||||
public onTap: Phaser.Signal;
|
||||
|
||||
/**
|
||||
* A Signal dispatched when a Pointer object (including the mouse) is held down
|
||||
* @type {Phaser.Signal}
|
||||
*/
|
||||
public onHold: Phaser.Signal;
|
||||
|
||||
/**
|
||||
* The number of milliseconds that the Pointer has to be pressed down and then released to be considered a tap or click
|
||||
* @property tapRate
|
||||
* @type {Number}
|
||||
**/
|
||||
public tapRate: number = 200;
|
||||
|
||||
/**
|
||||
* The number of milliseconds between taps of the same Pointer for it to be considered a double tap / click
|
||||
* @property doubleTapRate
|
||||
* @type {Number}
|
||||
**/
|
||||
public doubleTapRate: number = 300;
|
||||
|
||||
/**
|
||||
* The number of milliseconds that the Pointer has to be pressed down for it to fire a onHold event
|
||||
* @property holdRate
|
||||
* @type {Number}
|
||||
**/
|
||||
public holdRate: number = 2000;
|
||||
|
||||
/**
|
||||
* The number of milliseconds below which the Pointer is considered justPressed
|
||||
* @property justPressedRate
|
||||
* @type {Number}
|
||||
**/
|
||||
public justPressedRate: number = 200;
|
||||
|
||||
/**
|
||||
* The number of milliseconds below which the Pointer is considered justReleased
|
||||
* @property justReleasedRate
|
||||
* @type {Number}
|
||||
**/
|
||||
public justReleasedRate: number = 200;
|
||||
|
||||
/**
|
||||
* Sets if the Pointer objects should record a history of x/y coordinates they have passed through.
|
||||
* The history is cleared each time the Pointer is pressed down.
|
||||
* The history is updated at the rate specified in Input.pollRate
|
||||
* @property recordPointerHistory
|
||||
* @type {Boolean}
|
||||
**/
|
||||
public recordPointerHistory: bool = false;
|
||||
|
||||
/**
|
||||
* The rate in milliseconds at which the Pointer objects should update their tracking history
|
||||
* @property recordRate
|
||||
* @type {Number}
|
||||
*/
|
||||
public recordRate: number = 100;
|
||||
|
||||
/**
|
||||
* The total number of entries that can be recorded into the Pointer objects tracking history.
|
||||
* If the Pointer is tracking one event every 100ms, then a trackLimit of 100 would store the last 10 seconds worth of history.
|
||||
* @property recordLimit
|
||||
* @type {Number}
|
||||
*/
|
||||
public recordLimit: number = 100;
|
||||
|
||||
/**
|
||||
* A Pointer object specifically used by the Mouse
|
||||
* @property mousePointer
|
||||
* @type {Pointer}
|
||||
**/
|
||||
public mousePointer: Pointer;
|
||||
|
||||
/**
|
||||
* A Pointer object
|
||||
* @property pointer1
|
||||
* @type {Pointer}
|
||||
**/
|
||||
public pointer1: Pointer;
|
||||
|
||||
/**
|
||||
* A Pointer object
|
||||
* @property pointer2
|
||||
* @type {Pointer}
|
||||
**/
|
||||
public pointer2: Pointer;
|
||||
|
||||
/**
|
||||
* A Pointer object
|
||||
* @property pointer3
|
||||
* @type {Pointer}
|
||||
**/
|
||||
public pointer3: Pointer;
|
||||
|
||||
/**
|
||||
* A Pointer object
|
||||
* @property pointer4
|
||||
* @type {Pointer}
|
||||
**/
|
||||
public pointer4: Pointer;
|
||||
|
||||
/**
|
||||
* A Pointer object
|
||||
* @property pointer5
|
||||
* @type {Pointer}
|
||||
**/
|
||||
public pointer5: Pointer;
|
||||
|
||||
/**
|
||||
* A Pointer object
|
||||
* @property pointer6
|
||||
* @type {Pointer}
|
||||
**/
|
||||
public pointer6: Pointer = null;
|
||||
|
||||
/**
|
||||
* A Pointer object
|
||||
* @property pointer7
|
||||
* @type {Pointer}
|
||||
**/
|
||||
public pointer7: Pointer = null;
|
||||
|
||||
/**
|
||||
* A Pointer object
|
||||
* @property pointer8
|
||||
* @type {Pointer}
|
||||
**/
|
||||
public pointer8: Pointer = null;
|
||||
|
||||
/**
|
||||
* A Pointer object
|
||||
* @property pointer9
|
||||
* @type {Pointer}
|
||||
**/
|
||||
public pointer9: Pointer = null;
|
||||
|
||||
/**
|
||||
* A Pointer object
|
||||
* @property pointer10
|
||||
* @type {Pointer}
|
||||
**/
|
||||
public pointer10: Pointer = null;
|
||||
|
||||
/**
|
||||
* The most recently active Pointer object.
|
||||
* When you've limited max pointers to 1 this will accurately be either the first finger touched or mouse.
|
||||
* @property activePointer
|
||||
* @type {Pointer}
|
||||
**/
|
||||
public activePointer: Pointer = null;
|
||||
|
||||
public inputObjects = [];
|
||||
|
||||
public totalTrackedObjects: number = 0;
|
||||
|
||||
/**
|
||||
* The X coordinate of the most recently active pointer.
|
||||
* This value takes game scaling into account automatically. See Pointer.screenX/clientX for source values.
|
||||
* @property x
|
||||
* @type {Number}
|
||||
**/
|
||||
public get x(): number {
|
||||
return this._x;
|
||||
}
|
||||
|
||||
public set x(value: number) {
|
||||
this._x = Math.round(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* The Y coordinate of the most recently active pointer.
|
||||
* This value takes game scaling into account automatically. See Pointer.screenY/clientY for source values.
|
||||
* @property y
|
||||
* @type {Number}
|
||||
**/
|
||||
public get y(): number {
|
||||
return this._y;
|
||||
}
|
||||
|
||||
public set y(value: number) {
|
||||
this._y = Math.round(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new Pointer object to the Input Manager. By default Input creates 5 pointer objects for you. If you need more
|
||||
* use this to create a new one, up to a maximum of 10.
|
||||
* @method addPointer
|
||||
* @return {Pointer} A reference to the new Pointer object
|
||||
**/
|
||||
public addPointer(): Pointer {
|
||||
|
||||
var next: number = 0;
|
||||
|
||||
if (this.pointer10 === null)
|
||||
{
|
||||
next = 10;
|
||||
}
|
||||
|
||||
if (this.pointer9 === null)
|
||||
{
|
||||
next = 9;
|
||||
}
|
||||
|
||||
if (this.pointer8 === null)
|
||||
{
|
||||
next = 8;
|
||||
}
|
||||
|
||||
if (this.pointer7 === null)
|
||||
{
|
||||
next = 7;
|
||||
}
|
||||
|
||||
if (this.pointer6 === null)
|
||||
{
|
||||
next = 6;
|
||||
}
|
||||
|
||||
if (next == 0)
|
||||
{
|
||||
throw new Error("You can only have 10 Pointer objects");
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
this['pointer' + next] = new Pointer(this.game, next);
|
||||
return this['pointer' + next];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the Input Manager running
|
||||
* @method start
|
||||
**/
|
||||
public boot() {
|
||||
|
||||
this.mouse.start();
|
||||
this.keyboard.start();
|
||||
this.touch.start();
|
||||
this.mspointer.start();
|
||||
this.gestures.start();
|
||||
|
||||
this.mousePointer.active = true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new game object to be tracked by the Input Manager. Called by the Sprite.Input component, should not usually be called directly.
|
||||
* @method addGameObject
|
||||
**/
|
||||
public addGameObject(object) {
|
||||
|
||||
// Find a spare slot
|
||||
for (var i = 0; i < this.inputObjects.length; i++)
|
||||
{
|
||||
if (this.inputObjects[i] == null)
|
||||
{
|
||||
this.inputObjects[i] = object;
|
||||
object.input.indexID = i;
|
||||
this.totalTrackedObjects++;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// If we got this far we need to push a new entry into the array
|
||||
object.input.indexID = this.inputObjects.length;
|
||||
|
||||
this.inputObjects.push(object);
|
||||
|
||||
this.totalTrackedObjects++;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a game object from the Input Manager. Called by the Sprite.Input component, should not usually be called directly.
|
||||
* @method removeGameObject
|
||||
**/
|
||||
public removeGameObject(index: number) {
|
||||
|
||||
if (this.inputObjects[index])
|
||||
{
|
||||
this.inputObjects[index] = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the Input Manager. Called by the core Game loop.
|
||||
* @method update
|
||||
**/
|
||||
public update() {
|
||||
|
||||
this.speed.x = this.position.x - this._oldPosition.x;
|
||||
this.speed.y = this.position.y - this._oldPosition.y;
|
||||
|
||||
this._oldPosition.copyFrom(this.position);
|
||||
|
||||
this.mousePointer.update();
|
||||
this.pointer1.update();
|
||||
this.pointer2.update();
|
||||
this.pointer3.update();
|
||||
this.pointer4.update();
|
||||
this.pointer5.update();
|
||||
|
||||
if (this.pointer6) { this.pointer6.update(); }
|
||||
if (this.pointer7) { this.pointer7.update(); }
|
||||
if (this.pointer8) { this.pointer8.update(); }
|
||||
if (this.pointer9) { this.pointer9.update(); }
|
||||
if (this.pointer10) { this.pointer10.update(); }
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset all of the Pointers and Input states
|
||||
* @method reset
|
||||
* @param hard {Boolean} A soft reset (hard = false) won't reset any signals that might be bound. A hard reset will.
|
||||
**/
|
||||
public reset(hard?: bool = false) {
|
||||
|
||||
this.keyboard.reset();
|
||||
|
||||
this.mousePointer.reset();
|
||||
this.pointer1.reset();
|
||||
this.pointer2.reset();
|
||||
this.pointer3.reset();
|
||||
this.pointer4.reset();
|
||||
this.pointer5.reset();
|
||||
|
||||
if (this.pointer6) { this.pointer6.reset(); }
|
||||
if (this.pointer7) { this.pointer7.reset(); }
|
||||
if (this.pointer8) { this.pointer8.reset(); }
|
||||
if (this.pointer9) { this.pointer9.reset(); }
|
||||
if (this.pointer10) { this.pointer10.reset(); }
|
||||
|
||||
this.currentPointers = 0;
|
||||
|
||||
this.game.stage.canvas.style.cursor = "default";
|
||||
|
||||
if (hard == true)
|
||||
{
|
||||
this.onDown.dispose();
|
||||
this.onUp.dispose();
|
||||
this.onTap.dispose();
|
||||
this.onHold.dispose();
|
||||
|
||||
this.onDown = new Phaser.Signal();
|
||||
this.onUp = new Phaser.Signal();
|
||||
this.onTap = new Phaser.Signal();
|
||||
this.onHold = new Phaser.Signal();
|
||||
|
||||
for (var i = 0; i < this.totalTrackedObjects; i++)
|
||||
{
|
||||
if (this.inputObjects[i] && this.inputObjects[i].input)
|
||||
{
|
||||
this.inputObjects[i].input.reset();
|
||||
}
|
||||
}
|
||||
|
||||
this.inputObjects.length = 0;
|
||||
this.totalTrackedObjects = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public resetSpeed(x: number, y: number) {
|
||||
this._oldPosition.setTo(x, y);
|
||||
this.speed.setTo(0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the total number of inactive Pointers
|
||||
* @method totalInactivePointers
|
||||
* @return {Number} The number of Pointers currently inactive
|
||||
**/
|
||||
public get totalInactivePointers(): number {
|
||||
|
||||
return 10 - this.currentPointers;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Recalculates the total number of active Pointers
|
||||
* @method totalActivePointers
|
||||
* @return {Number} The number of Pointers currently active
|
||||
**/
|
||||
public get totalActivePointers(): number {
|
||||
|
||||
this.currentPointers = 0;
|
||||
|
||||
if (this.pointer1.active == true)
|
||||
{
|
||||
this.currentPointers++;
|
||||
}
|
||||
else if (this.pointer2.active == true)
|
||||
{
|
||||
this.currentPointers++;
|
||||
}
|
||||
else if (this.pointer3.active == true)
|
||||
{
|
||||
this.currentPointers++;
|
||||
}
|
||||
else if (this.pointer4.active == true)
|
||||
{
|
||||
this.currentPointers++;
|
||||
}
|
||||
else if (this.pointer5.active == true)
|
||||
{
|
||||
this.currentPointers++;
|
||||
}
|
||||
else if (this.pointer6 && this.pointer6.active == true)
|
||||
{
|
||||
this.currentPointers++;
|
||||
}
|
||||
else if (this.pointer7 && this.pointer7.active == true)
|
||||
{
|
||||
this.currentPointers++;
|
||||
}
|
||||
else if (this.pointer8 && this.pointer8.active == true)
|
||||
{
|
||||
this.currentPointers++;
|
||||
}
|
||||
else if (this.pointer9 && this.pointer9.active == true)
|
||||
{
|
||||
this.currentPointers++;
|
||||
}
|
||||
else if (this.pointer10 && this.pointer10.active == true)
|
||||
{
|
||||
this.currentPointers++;
|
||||
}
|
||||
|
||||
return this.currentPointers;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the first free Pointer object and start it, passing in the event data.
|
||||
* @method startPointer
|
||||
* @param {Any} event The event data from the Touch event
|
||||
* @return {Pointer} The Pointer object that was started or null if no Pointer object is available
|
||||
**/
|
||||
public startPointer(event): Pointer {
|
||||
|
||||
if (this.maxPointers < 10 && this.totalActivePointers == this.maxPointers)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// Unrolled for speed
|
||||
if (this.pointer1.active == false)
|
||||
{
|
||||
return this.pointer1.start(event);
|
||||
}
|
||||
else if (this.pointer2.active == false)
|
||||
{
|
||||
return this.pointer2.start(event);
|
||||
}
|
||||
else if (this.pointer3.active == false)
|
||||
{
|
||||
return this.pointer3.start(event);
|
||||
}
|
||||
else if (this.pointer4.active == false)
|
||||
{
|
||||
return this.pointer4.start(event);
|
||||
}
|
||||
else if (this.pointer5.active == false)
|
||||
{
|
||||
return this.pointer5.start(event);
|
||||
}
|
||||
else if (this.pointer6 && this.pointer6.active == false)
|
||||
{
|
||||
return this.pointer6.start(event);
|
||||
}
|
||||
else if (this.pointer7 && this.pointer7.active == false)
|
||||
{
|
||||
return this.pointer7.start(event);
|
||||
}
|
||||
else if (this.pointer8 && this.pointer8.active == false)
|
||||
{
|
||||
return this.pointer8.start(event);
|
||||
}
|
||||
else if (this.pointer9 && this.pointer9.active == false)
|
||||
{
|
||||
return this.pointer9.start(event);
|
||||
}
|
||||
else if (this.pointer10 && this.pointer10.active == false)
|
||||
{
|
||||
return this.pointer10.start(event);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the matching Pointer object, passing in the event data.
|
||||
* @method updatePointer
|
||||
* @param {Any} event The event data from the Touch event
|
||||
* @return {Pointer} The Pointer object that was updated or null if no Pointer object is available
|
||||
**/
|
||||
public updatePointer(event): Pointer {
|
||||
|
||||
// Unrolled for speed
|
||||
if (this.pointer1.active == true && this.pointer1.identifier == event.identifier)
|
||||
{
|
||||
return this.pointer1.move(event);
|
||||
}
|
||||
else if (this.pointer2.active == true && this.pointer2.identifier == event.identifier)
|
||||
{
|
||||
return this.pointer2.move(event);
|
||||
}
|
||||
else if (this.pointer3.active == true && this.pointer3.identifier == event.identifier)
|
||||
{
|
||||
return this.pointer3.move(event);
|
||||
}
|
||||
else if (this.pointer4.active == true && this.pointer4.identifier == event.identifier)
|
||||
{
|
||||
return this.pointer4.move(event);
|
||||
}
|
||||
else if (this.pointer5.active == true && this.pointer5.identifier == event.identifier)
|
||||
{
|
||||
return this.pointer5.move(event);
|
||||
}
|
||||
else if (this.pointer6 && this.pointer6.active == true && this.pointer6.identifier == event.identifier)
|
||||
{
|
||||
return this.pointer6.move(event);
|
||||
}
|
||||
else if (this.pointer7 && this.pointer7.active == true && this.pointer7.identifier == event.identifier)
|
||||
{
|
||||
return this.pointer7.move(event);
|
||||
}
|
||||
else if (this.pointer8 && this.pointer8.active == true && this.pointer8.identifier == event.identifier)
|
||||
{
|
||||
return this.pointer8.move(event);
|
||||
}
|
||||
else if (this.pointer9 && this.pointer9.active == true && this.pointer9.identifier == event.identifier)
|
||||
{
|
||||
return this.pointer9.move(event);
|
||||
}
|
||||
else if (this.pointer10 && this.pointer10.active == true && this.pointer10.identifier == event.identifier)
|
||||
{
|
||||
return this.pointer10.move(event);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops the matching Pointer object, passing in the event data.
|
||||
* @method stopPointer
|
||||
* @param {Any} event The event data from the Touch event
|
||||
* @return {Pointer} The Pointer object that was stopped or null if no Pointer object is available
|
||||
**/
|
||||
public stopPointer(event): Pointer {
|
||||
|
||||
// Unrolled for speed
|
||||
if (this.pointer1.active == true && this.pointer1.identifier == event.identifier)
|
||||
{
|
||||
return this.pointer1.stop(event);
|
||||
}
|
||||
else if (this.pointer2.active == true && this.pointer2.identifier == event.identifier)
|
||||
{
|
||||
return this.pointer2.stop(event);
|
||||
}
|
||||
else if (this.pointer3.active == true && this.pointer3.identifier == event.identifier)
|
||||
{
|
||||
return this.pointer3.stop(event);
|
||||
}
|
||||
else if (this.pointer4.active == true && this.pointer4.identifier == event.identifier)
|
||||
{
|
||||
return this.pointer4.stop(event);
|
||||
}
|
||||
else if (this.pointer5.active == true && this.pointer5.identifier == event.identifier)
|
||||
{
|
||||
return this.pointer5.stop(event);
|
||||
}
|
||||
else if (this.pointer6 && this.pointer6.active == true && this.pointer6.identifier == event.identifier)
|
||||
{
|
||||
return this.pointer6.stop(event);
|
||||
}
|
||||
else if (this.pointer7 && this.pointer7.active == true && this.pointer7.identifier == event.identifier)
|
||||
{
|
||||
return this.pointer7.stop(event);
|
||||
}
|
||||
else if (this.pointer8 && this.pointer8.active == true && this.pointer8.identifier == event.identifier)
|
||||
{
|
||||
return this.pointer8.stop(event);
|
||||
}
|
||||
else if (this.pointer9 && this.pointer9.active == true && this.pointer9.identifier == event.identifier)
|
||||
{
|
||||
return this.pointer9.stop(event);
|
||||
}
|
||||
else if (this.pointer10 && this.pointer10.active == true && this.pointer10.identifier == event.identifier)
|
||||
{
|
||||
return this.pointer10.stop(event);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the next Pointer object whos active property matches the given state
|
||||
* @method getPointer
|
||||
* @param {Boolean} state The state the Pointer should be in (false for inactive, true for active)
|
||||
* @return {Pointer} A Pointer object or null if no Pointer object matches the requested state.
|
||||
**/
|
||||
public getPointer(state: bool = false): Pointer {
|
||||
|
||||
// Unrolled for speed
|
||||
if (this.pointer1.active == state)
|
||||
{
|
||||
return this.pointer1;
|
||||
}
|
||||
else if (this.pointer2.active == state)
|
||||
{
|
||||
return this.pointer2;
|
||||
}
|
||||
else if (this.pointer3.active == state)
|
||||
{
|
||||
return this.pointer3;
|
||||
}
|
||||
else if (this.pointer4.active == state)
|
||||
{
|
||||
return this.pointer4;
|
||||
}
|
||||
else if (this.pointer5.active == state)
|
||||
{
|
||||
return this.pointer5;
|
||||
}
|
||||
else if (this.pointer6 && this.pointer6.active == state)
|
||||
{
|
||||
return this.pointer6;
|
||||
}
|
||||
else if (this.pointer7 && this.pointer7.active == state)
|
||||
{
|
||||
return this.pointer7;
|
||||
}
|
||||
else if (this.pointer8 && this.pointer8.active == state)
|
||||
{
|
||||
return this.pointer8;
|
||||
}
|
||||
else if (this.pointer9 && this.pointer9.active == state)
|
||||
{
|
||||
return this.pointer9;
|
||||
}
|
||||
else if (this.pointer10 && this.pointer10.active == state)
|
||||
{
|
||||
return this.pointer10;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Pointer object whos identified property matches the given identifier value
|
||||
* @method getPointerFromIdentifier
|
||||
* @param {Number} identifier The Pointer.identifier value to search for
|
||||
* @return {Pointer} A Pointer object or null if no Pointer object matches the requested identifier.
|
||||
**/
|
||||
public getPointerFromIdentifier(identifier: number): Pointer {
|
||||
|
||||
// Unrolled for speed
|
||||
if (this.pointer1.identifier == identifier)
|
||||
{
|
||||
return this.pointer1;
|
||||
}
|
||||
else if (this.pointer2.identifier == identifier)
|
||||
{
|
||||
return this.pointer2;
|
||||
}
|
||||
else if (this.pointer3.identifier == identifier)
|
||||
{
|
||||
return this.pointer3;
|
||||
}
|
||||
else if (this.pointer4.identifier == identifier)
|
||||
{
|
||||
return this.pointer4;
|
||||
}
|
||||
else if (this.pointer5.identifier == identifier)
|
||||
{
|
||||
return this.pointer5;
|
||||
}
|
||||
else if (this.pointer6 && this.pointer6.identifier == identifier)
|
||||
{
|
||||
return this.pointer6;
|
||||
}
|
||||
else if (this.pointer7 && this.pointer7.identifier == identifier)
|
||||
{
|
||||
return this.pointer7;
|
||||
}
|
||||
else if (this.pointer8 && this.pointer8.identifier == identifier)
|
||||
{
|
||||
return this.pointer8;
|
||||
}
|
||||
else if (this.pointer9 && this.pointer9.identifier == identifier)
|
||||
{
|
||||
return this.pointer9;
|
||||
}
|
||||
else if (this.pointer10 && this.pointer10.identifier == identifier)
|
||||
{
|
||||
return this.pointer10;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Camera} [camera]
|
||||
*/
|
||||
public getWorldX(camera?: Camera = this.game.camera) {
|
||||
return camera.worldView.x + this.x;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Camera} [camera]
|
||||
*/
|
||||
public getWorldY(camera?: Camera = this.game.camera) {
|
||||
return camera.worldView.y + this.y;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Number} x
|
||||
* @param {Number} y
|
||||
* @param {String} [color]
|
||||
*/
|
||||
public renderDebugInfo(x: number, y: number, color?: string = 'rgb(255,255,255)') {
|
||||
|
||||
this.game.stage.context.fillStyle = color;
|
||||
this.game.stage.context.fillText('Input', x, y);
|
||||
this.game.stage.context.fillText('X: ' + this.x + ' Y: ' + this.y, x, y + 14);
|
||||
this.game.stage.context.fillText('World X: ' + this.getWorldX() + ' World Y: ' + this.getWorldY(), x, y + 28);
|
||||
this.game.stage.context.fillText('Scale X: ' + this.scale.x.toFixed(1) + ' Scale Y: ' + this.scale.x.toFixed(1), x, y + 42);
|
||||
this.game.stage.context.fillText('Screen X: ' + this.activePointer.screenX + ' Screen Y: ' + this.activePointer.screenY, x, y + 56);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the distance between two Pointer objects
|
||||
* @method getDistance
|
||||
* @param {Pointer} pointer1
|
||||
* @param {Pointer} pointer2
|
||||
**/
|
||||
public getDistance(pointer1: Pointer, pointer2: Pointer): number {
|
||||
return Vec2Utils.distance(pointer1.position, pointer2.position);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the angle between two Pointer objects
|
||||
* @method getAngle
|
||||
* @param {Pointer} pointer1
|
||||
* @param {Pointer} pointer2
|
||||
**/
|
||||
public getAngle(pointer1: Pointer, pointer2: Pointer): number {
|
||||
return Vec2Utils.angle(pointer1.position, pointer2.position);
|
||||
}
|
||||
|
||||
public pixelPerfectCheck(sprite: Phaser.Sprite, pointer: Phaser.Pointer, alpha: number = 255): bool {
|
||||
|
||||
this.hitContext.clearRect(0, 0, 1, 1);
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,17 +1,16 @@
|
||||
/// <reference path="../../Game.ts" />
|
||||
/// <reference path="../../gameobjects/DynamicTexture.ts" />
|
||||
/// <reference path="../../utils/SpriteUtils.ts" />
|
||||
/// <reference path="../../utils/RectangleUtils.ts" />
|
||||
/// <reference path="../Game.ts" />
|
||||
/// <reference path="../utils/SpriteUtils.ts" />
|
||||
/// <reference path="../utils/RectangleUtils.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Components - Input
|
||||
* Phaser - Components - InputHandler
|
||||
*
|
||||
* Input detection component
|
||||
*/
|
||||
|
||||
module Phaser.Components.Sprite {
|
||||
module Phaser.Components {
|
||||
|
||||
export class Input {
|
||||
export class InputHandler {
|
||||
|
||||
/**
|
||||
* Sprite Input component constructor
|
||||
@@ -0,0 +1,999 @@
|
||||
/// <reference path="../Game.ts" />
|
||||
/// <reference path="../core/Signal.ts" />
|
||||
/// <reference path="../utils/PointUtils.ts" />
|
||||
/// <reference path="../math/Vec2Utils.ts" />
|
||||
/// <reference path="Pointer.ts" />
|
||||
/// <reference path="MSPointer.ts" />
|
||||
/// <reference path="Gestures.ts" />
|
||||
/// <reference path="Mouse.ts" />
|
||||
/// <reference path="Keyboard.ts" />
|
||||
/// <reference path="Touch.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - InputManager
|
||||
*
|
||||
* A game specific Input manager that looks after the mouse, keyboard and touch objects.
|
||||
* This is updated by the core game loop.
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class InputManager {
|
||||
|
||||
constructor(game: Game) {
|
||||
|
||||
this.game = game;
|
||||
|
||||
this.mousePointer = new Pointer(this.game, 0);
|
||||
this.pointer1 = new Pointer(this.game, 1);
|
||||
this.pointer2 = new Pointer(this.game, 2);
|
||||
this.pointer3 = new Pointer(this.game, 3);
|
||||
this.pointer4 = new Pointer(this.game, 4);
|
||||
this.pointer5 = new Pointer(this.game, 5);
|
||||
|
||||
this.mouse = new Mouse(this.game);
|
||||
this.keyboard = new Keyboard(this.game);
|
||||
this.touch = new Touch(this.game);
|
||||
this.mspointer = new MSPointer(this.game);
|
||||
this.gestures = new Gestures(this.game);
|
||||
|
||||
this.onDown = new Phaser.Signal();
|
||||
this.onUp = new Phaser.Signal();
|
||||
this.onTap = new Phaser.Signal();
|
||||
this.onHold = new Phaser.Signal();
|
||||
|
||||
this.scale = new Vec2(1, 1);
|
||||
this.speed = new Vec2;
|
||||
this.position = new Vec2;
|
||||
this._oldPosition = new Vec2;
|
||||
this.circle = new Circle(0, 0, 44);
|
||||
|
||||
this.camera = this.game.camera;
|
||||
|
||||
this.activePointer = this.mousePointer;
|
||||
this.currentPointers = 0;
|
||||
|
||||
this.hitCanvas = <HTMLCanvasElement> document.createElement('canvas');
|
||||
this.hitCanvas.width = 1;
|
||||
this.hitCanvas.height = 1;
|
||||
this.hitContext = this.hitCanvas.getContext('2d');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Local reference to game.
|
||||
*/
|
||||
public game: Game;
|
||||
|
||||
/**
|
||||
* A 1x1 sized canvas used for pixel-perfect checks
|
||||
* @type {HTMLCanvasElement}
|
||||
*/
|
||||
public hitCanvas: HTMLCanvasElement;
|
||||
|
||||
/**
|
||||
* The context of the 1x1 pixel check canvas
|
||||
* @type {CanvasRenderingContext2D}
|
||||
*/
|
||||
public hitContext: CanvasRenderingContext2D;
|
||||
|
||||
/**
|
||||
* A vector object representing the previous position of the Pointer.
|
||||
* @property vector
|
||||
* @type {Vec2}
|
||||
**/
|
||||
private _oldPosition: Vec2 = null;
|
||||
|
||||
/**
|
||||
* X coordinate of the most recent Pointer event
|
||||
* @type {Number}
|
||||
* @private
|
||||
*/
|
||||
private _x: number = 0;
|
||||
|
||||
/**
|
||||
* X coordinate of the most recent Pointer event
|
||||
* @type {Number}
|
||||
* @private
|
||||
*/
|
||||
private _y: number = 0;
|
||||
|
||||
/**
|
||||
* You can disable all Input by setting Input.disabled = true. While set all new input related events will be ignored.
|
||||
* If you need to disable just one type of input, for example mouse, use Input.mouse.disabled = true instead
|
||||
* @type {Boolean}
|
||||
*/
|
||||
public disabled: bool = false;
|
||||
|
||||
/**
|
||||
* Controls the expected behaviour when using a mouse and touch together on a multi-input device
|
||||
*/
|
||||
public multiInputOverride: number = InputManager.MOUSE_TOUCH_COMBINE;
|
||||
|
||||
/**
|
||||
* Static defining the behaviour expected on a multi-input device system.
|
||||
* With this setting when the mouse is used it updates the Input.x/y globals regardless if another pointer is active or not
|
||||
*/
|
||||
public static MOUSE_OVERRIDES_TOUCH: number = 0;
|
||||
|
||||
/**
|
||||
* Static defining the behaviour expected on a multi-input device system.
|
||||
* With this setting when the mouse is used it only updates the Input.x/y globals if no other pointer is active
|
||||
*/
|
||||
public static TOUCH_OVERRIDES_MOUSE: number = 1;
|
||||
|
||||
/**
|
||||
* Static defining the behaviour expected on a multi-input device system.
|
||||
* With this setting when the mouse is used it updates the Input.x/y globals at the same time as any active Pointer objects might
|
||||
*/
|
||||
public static MOUSE_TOUCH_COMBINE: number = 2;
|
||||
|
||||
/**
|
||||
* The camera being used for mouse and touch based pointers to calculate their world coordinates.
|
||||
* @property camera
|
||||
* @type {Camera}
|
||||
**/
|
||||
public camera: Camera;
|
||||
|
||||
/**
|
||||
* Phaser.Mouse handler
|
||||
* @type {Mouse}
|
||||
*/
|
||||
public mouse: Mouse;
|
||||
|
||||
/**
|
||||
* Phaser.Keyboard handler
|
||||
* @type {Keyboard}
|
||||
*/
|
||||
public keyboard: Keyboard;
|
||||
|
||||
/**
|
||||
* Phaser.Touch handler
|
||||
* @type {Touch}
|
||||
*/
|
||||
public touch: Touch;
|
||||
|
||||
/**
|
||||
* Phaser.MSPointer handler
|
||||
* @type {MSPointer}
|
||||
*/
|
||||
public mspointer: MSPointer;
|
||||
|
||||
/**
|
||||
* Phaser.Gestures handler
|
||||
* @type {Gestures}
|
||||
*/
|
||||
public gestures: Gestures;
|
||||
|
||||
/**
|
||||
* A vector object representing the current position of the Pointer.
|
||||
* @property vector
|
||||
* @type {Vec2}
|
||||
**/
|
||||
public position: Vec2 = null;
|
||||
|
||||
/**
|
||||
* A vector object representing the speed of the Pointer. Only really useful in single Pointer games,
|
||||
* otherwise see the Pointer objects directly.
|
||||
* @property vector
|
||||
* @type {Vec2}
|
||||
**/
|
||||
public speed: Vec2 = null;
|
||||
|
||||
/**
|
||||
* A Circle object centered on the x/y screen coordinates of the Input.
|
||||
* Default size of 44px (Apples recommended "finger tip" size) but can be changed to anything
|
||||
* @property circle
|
||||
* @type {Circle}
|
||||
**/
|
||||
public circle: Circle = null;
|
||||
|
||||
/**
|
||||
* The scale by which all input coordinates are multiplied, calculated by the StageScaleMode.
|
||||
* In an un-scaled game the values will be x: 1 and y: 1.
|
||||
* @type {Vec2}
|
||||
*/
|
||||
public scale: Vec2 = null;
|
||||
|
||||
/**
|
||||
* The maximum number of Pointers allowed to be active at any one time.
|
||||
* For lots of games it's useful to set this to 1
|
||||
* @type {Number}
|
||||
*/
|
||||
public maxPointers: number = 10;
|
||||
|
||||
/**
|
||||
* The current number of active Pointers.
|
||||
* @type {Number}
|
||||
*/
|
||||
public currentPointers: number = 0;
|
||||
|
||||
/**
|
||||
* A Signal dispatched when a mouse/Pointer object is pressed
|
||||
* @type {Phaser.Signal}
|
||||
*/
|
||||
public onDown: Phaser.Signal;
|
||||
|
||||
/**
|
||||
* A Signal dispatched when a mouse/Pointer object is released
|
||||
* @type {Phaser.Signal}
|
||||
*/
|
||||
public onUp: Phaser.Signal;
|
||||
|
||||
/**
|
||||
* A Signal dispatched when a Pointer object (including the mouse) is tapped: pressed and released quickly.
|
||||
* The signal sends 2 parameters. The Pointer that caused it and a boolean depending if the tap was a single tap or a double tap.
|
||||
* @type {Phaser.Signal}
|
||||
*/
|
||||
public onTap: Phaser.Signal;
|
||||
|
||||
/**
|
||||
* A Signal dispatched when a Pointer object (including the mouse) is held down
|
||||
* @type {Phaser.Signal}
|
||||
*/
|
||||
public onHold: Phaser.Signal;
|
||||
|
||||
/**
|
||||
* The number of milliseconds that the Pointer has to be pressed down and then released to be considered a tap or click
|
||||
* @property tapRate
|
||||
* @type {Number}
|
||||
**/
|
||||
public tapRate: number = 200;
|
||||
|
||||
/**
|
||||
* The number of milliseconds between taps of the same Pointer for it to be considered a double tap / click
|
||||
* @property doubleTapRate
|
||||
* @type {Number}
|
||||
**/
|
||||
public doubleTapRate: number = 300;
|
||||
|
||||
/**
|
||||
* The number of milliseconds that the Pointer has to be pressed down for it to fire a onHold event
|
||||
* @property holdRate
|
||||
* @type {Number}
|
||||
**/
|
||||
public holdRate: number = 2000;
|
||||
|
||||
/**
|
||||
* The number of milliseconds below which the Pointer is considered justPressed
|
||||
* @property justPressedRate
|
||||
* @type {Number}
|
||||
**/
|
||||
public justPressedRate: number = 200;
|
||||
|
||||
/**
|
||||
* The number of milliseconds below which the Pointer is considered justReleased
|
||||
* @property justReleasedRate
|
||||
* @type {Number}
|
||||
**/
|
||||
public justReleasedRate: number = 200;
|
||||
|
||||
/**
|
||||
* Sets if the Pointer objects should record a history of x/y coordinates they have passed through.
|
||||
* The history is cleared each time the Pointer is pressed down.
|
||||
* The history is updated at the rate specified in Input.pollRate
|
||||
* @property recordPointerHistory
|
||||
* @type {Boolean}
|
||||
**/
|
||||
public recordPointerHistory: bool = false;
|
||||
|
||||
/**
|
||||
* The rate in milliseconds at which the Pointer objects should update their tracking history
|
||||
* @property recordRate
|
||||
* @type {Number}
|
||||
*/
|
||||
public recordRate: number = 100;
|
||||
|
||||
/**
|
||||
* The total number of entries that can be recorded into the Pointer objects tracking history.
|
||||
* If the Pointer is tracking one event every 100ms, then a trackLimit of 100 would store the last 10 seconds worth of history.
|
||||
* @property recordLimit
|
||||
* @type {Number}
|
||||
*/
|
||||
public recordLimit: number = 100;
|
||||
|
||||
/**
|
||||
* A Pointer object specifically used by the Mouse
|
||||
* @property mousePointer
|
||||
* @type {Pointer}
|
||||
**/
|
||||
public mousePointer: Pointer;
|
||||
|
||||
/**
|
||||
* A Pointer object
|
||||
* @property pointer1
|
||||
* @type {Pointer}
|
||||
**/
|
||||
public pointer1: Pointer;
|
||||
|
||||
/**
|
||||
* A Pointer object
|
||||
* @property pointer2
|
||||
* @type {Pointer}
|
||||
**/
|
||||
public pointer2: Pointer;
|
||||
|
||||
/**
|
||||
* A Pointer object
|
||||
* @property pointer3
|
||||
* @type {Pointer}
|
||||
**/
|
||||
public pointer3: Pointer;
|
||||
|
||||
/**
|
||||
* A Pointer object
|
||||
* @property pointer4
|
||||
* @type {Pointer}
|
||||
**/
|
||||
public pointer4: Pointer;
|
||||
|
||||
/**
|
||||
* A Pointer object
|
||||
* @property pointer5
|
||||
* @type {Pointer}
|
||||
**/
|
||||
public pointer5: Pointer;
|
||||
|
||||
/**
|
||||
* A Pointer object
|
||||
* @property pointer6
|
||||
* @type {Pointer}
|
||||
**/
|
||||
public pointer6: Pointer = null;
|
||||
|
||||
/**
|
||||
* A Pointer object
|
||||
* @property pointer7
|
||||
* @type {Pointer}
|
||||
**/
|
||||
public pointer7: Pointer = null;
|
||||
|
||||
/**
|
||||
* A Pointer object
|
||||
* @property pointer8
|
||||
* @type {Pointer}
|
||||
**/
|
||||
public pointer8: Pointer = null;
|
||||
|
||||
/**
|
||||
* A Pointer object
|
||||
* @property pointer9
|
||||
* @type {Pointer}
|
||||
**/
|
||||
public pointer9: Pointer = null;
|
||||
|
||||
/**
|
||||
* A Pointer object
|
||||
* @property pointer10
|
||||
* @type {Pointer}
|
||||
**/
|
||||
public pointer10: Pointer = null;
|
||||
|
||||
/**
|
||||
* The most recently active Pointer object.
|
||||
* When you've limited max pointers to 1 this will accurately be either the first finger touched or mouse.
|
||||
* @property activePointer
|
||||
* @type {Pointer}
|
||||
**/
|
||||
public activePointer: Pointer = null;
|
||||
|
||||
public inputObjects = [];
|
||||
|
||||
public totalTrackedObjects: number = 0;
|
||||
|
||||
/**
|
||||
* The X coordinate of the most recently active pointer.
|
||||
* This value takes game scaling into account automatically. See Pointer.screenX/clientX for source values.
|
||||
* @property x
|
||||
* @type {Number}
|
||||
**/
|
||||
public get x(): number {
|
||||
return this._x;
|
||||
}
|
||||
|
||||
public set x(value: number) {
|
||||
this._x = Math.round(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* The Y coordinate of the most recently active pointer.
|
||||
* This value takes game scaling into account automatically. See Pointer.screenY/clientY for source values.
|
||||
* @property y
|
||||
* @type {Number}
|
||||
**/
|
||||
public get y(): number {
|
||||
return this._y;
|
||||
}
|
||||
|
||||
public set y(value: number) {
|
||||
this._y = Math.round(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new Pointer object to the Input Manager. By default Input creates 5 pointer objects for you. If you need more
|
||||
* use this to create a new one, up to a maximum of 10.
|
||||
* @method addPointer
|
||||
* @return {Pointer} A reference to the new Pointer object
|
||||
**/
|
||||
public addPointer(): Pointer {
|
||||
|
||||
var next: number = 0;
|
||||
|
||||
if (this.pointer10 === null)
|
||||
{
|
||||
next = 10;
|
||||
}
|
||||
|
||||
if (this.pointer9 === null)
|
||||
{
|
||||
next = 9;
|
||||
}
|
||||
|
||||
if (this.pointer8 === null)
|
||||
{
|
||||
next = 8;
|
||||
}
|
||||
|
||||
if (this.pointer7 === null)
|
||||
{
|
||||
next = 7;
|
||||
}
|
||||
|
||||
if (this.pointer6 === null)
|
||||
{
|
||||
next = 6;
|
||||
}
|
||||
|
||||
if (next == 0)
|
||||
{
|
||||
throw new Error("You can only have 10 Pointer objects");
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
this['pointer' + next] = new Pointer(this.game, next);
|
||||
return this['pointer' + next];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the Input Manager running
|
||||
* @method start
|
||||
**/
|
||||
public boot() {
|
||||
|
||||
this.mouse.start();
|
||||
this.keyboard.start();
|
||||
this.touch.start();
|
||||
this.mspointer.start();
|
||||
this.gestures.start();
|
||||
|
||||
this.mousePointer.active = true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new game object to be tracked by the Input Manager. Called by the Sprite.Input component, should not usually be called directly.
|
||||
* @method addGameObject
|
||||
**/
|
||||
public addGameObject(object) {
|
||||
|
||||
// Find a spare slot
|
||||
for (var i = 0; i < this.inputObjects.length; i++)
|
||||
{
|
||||
if (this.inputObjects[i] == null)
|
||||
{
|
||||
this.inputObjects[i] = object;
|
||||
object.input.indexID = i;
|
||||
this.totalTrackedObjects++;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// If we got this far we need to push a new entry into the array
|
||||
object.input.indexID = this.inputObjects.length;
|
||||
|
||||
this.inputObjects.push(object);
|
||||
|
||||
this.totalTrackedObjects++;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a game object from the Input Manager. Called by the Sprite.Input component, should not usually be called directly.
|
||||
* @method removeGameObject
|
||||
**/
|
||||
public removeGameObject(index: number) {
|
||||
|
||||
if (this.inputObjects[index])
|
||||
{
|
||||
this.inputObjects[index] = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the Input Manager. Called by the core Game loop.
|
||||
* @method update
|
||||
**/
|
||||
public update() {
|
||||
|
||||
this.speed.x = this.position.x - this._oldPosition.x;
|
||||
this.speed.y = this.position.y - this._oldPosition.y;
|
||||
|
||||
this._oldPosition.copyFrom(this.position);
|
||||
|
||||
this.mousePointer.update();
|
||||
this.pointer1.update();
|
||||
this.pointer2.update();
|
||||
this.pointer3.update();
|
||||
this.pointer4.update();
|
||||
this.pointer5.update();
|
||||
|
||||
if (this.pointer6) { this.pointer6.update(); }
|
||||
if (this.pointer7) { this.pointer7.update(); }
|
||||
if (this.pointer8) { this.pointer8.update(); }
|
||||
if (this.pointer9) { this.pointer9.update(); }
|
||||
if (this.pointer10) { this.pointer10.update(); }
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset all of the Pointers and Input states
|
||||
* @method reset
|
||||
* @param hard {Boolean} A soft reset (hard = false) won't reset any signals that might be bound. A hard reset will.
|
||||
**/
|
||||
public reset(hard?: bool = false) {
|
||||
|
||||
this.keyboard.reset();
|
||||
|
||||
this.mousePointer.reset();
|
||||
this.pointer1.reset();
|
||||
this.pointer2.reset();
|
||||
this.pointer3.reset();
|
||||
this.pointer4.reset();
|
||||
this.pointer5.reset();
|
||||
|
||||
if (this.pointer6) { this.pointer6.reset(); }
|
||||
if (this.pointer7) { this.pointer7.reset(); }
|
||||
if (this.pointer8) { this.pointer8.reset(); }
|
||||
if (this.pointer9) { this.pointer9.reset(); }
|
||||
if (this.pointer10) { this.pointer10.reset(); }
|
||||
|
||||
this.currentPointers = 0;
|
||||
|
||||
this.game.stage.canvas.style.cursor = "default";
|
||||
|
||||
if (hard == true)
|
||||
{
|
||||
this.onDown.dispose();
|
||||
this.onUp.dispose();
|
||||
this.onTap.dispose();
|
||||
this.onHold.dispose();
|
||||
|
||||
this.onDown = new Phaser.Signal();
|
||||
this.onUp = new Phaser.Signal();
|
||||
this.onTap = new Phaser.Signal();
|
||||
this.onHold = new Phaser.Signal();
|
||||
|
||||
for (var i = 0; i < this.totalTrackedObjects; i++)
|
||||
{
|
||||
if (this.inputObjects[i] && this.inputObjects[i].input)
|
||||
{
|
||||
this.inputObjects[i].input.reset();
|
||||
}
|
||||
}
|
||||
|
||||
this.inputObjects.length = 0;
|
||||
this.totalTrackedObjects = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public resetSpeed(x: number, y: number) {
|
||||
this._oldPosition.setTo(x, y);
|
||||
this.speed.setTo(0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the total number of inactive Pointers
|
||||
* @method totalInactivePointers
|
||||
* @return {Number} The number of Pointers currently inactive
|
||||
**/
|
||||
public get totalInactivePointers(): number {
|
||||
|
||||
return 10 - this.currentPointers;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Recalculates the total number of active Pointers
|
||||
* @method totalActivePointers
|
||||
* @return {Number} The number of Pointers currently active
|
||||
**/
|
||||
public get totalActivePointers(): number {
|
||||
|
||||
this.currentPointers = 0;
|
||||
|
||||
if (this.pointer1.active == true)
|
||||
{
|
||||
this.currentPointers++;
|
||||
}
|
||||
else if (this.pointer2.active == true)
|
||||
{
|
||||
this.currentPointers++;
|
||||
}
|
||||
else if (this.pointer3.active == true)
|
||||
{
|
||||
this.currentPointers++;
|
||||
}
|
||||
else if (this.pointer4.active == true)
|
||||
{
|
||||
this.currentPointers++;
|
||||
}
|
||||
else if (this.pointer5.active == true)
|
||||
{
|
||||
this.currentPointers++;
|
||||
}
|
||||
else if (this.pointer6 && this.pointer6.active == true)
|
||||
{
|
||||
this.currentPointers++;
|
||||
}
|
||||
else if (this.pointer7 && this.pointer7.active == true)
|
||||
{
|
||||
this.currentPointers++;
|
||||
}
|
||||
else if (this.pointer8 && this.pointer8.active == true)
|
||||
{
|
||||
this.currentPointers++;
|
||||
}
|
||||
else if (this.pointer9 && this.pointer9.active == true)
|
||||
{
|
||||
this.currentPointers++;
|
||||
}
|
||||
else if (this.pointer10 && this.pointer10.active == true)
|
||||
{
|
||||
this.currentPointers++;
|
||||
}
|
||||
|
||||
return this.currentPointers;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the first free Pointer object and start it, passing in the event data.
|
||||
* @method startPointer
|
||||
* @param {Any} event The event data from the Touch event
|
||||
* @return {Pointer} The Pointer object that was started or null if no Pointer object is available
|
||||
**/
|
||||
public startPointer(event): Pointer {
|
||||
|
||||
if (this.maxPointers < 10 && this.totalActivePointers == this.maxPointers)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// Unrolled for speed
|
||||
if (this.pointer1.active == false)
|
||||
{
|
||||
return this.pointer1.start(event);
|
||||
}
|
||||
else if (this.pointer2.active == false)
|
||||
{
|
||||
return this.pointer2.start(event);
|
||||
}
|
||||
else if (this.pointer3.active == false)
|
||||
{
|
||||
return this.pointer3.start(event);
|
||||
}
|
||||
else if (this.pointer4.active == false)
|
||||
{
|
||||
return this.pointer4.start(event);
|
||||
}
|
||||
else if (this.pointer5.active == false)
|
||||
{
|
||||
return this.pointer5.start(event);
|
||||
}
|
||||
else if (this.pointer6 && this.pointer6.active == false)
|
||||
{
|
||||
return this.pointer6.start(event);
|
||||
}
|
||||
else if (this.pointer7 && this.pointer7.active == false)
|
||||
{
|
||||
return this.pointer7.start(event);
|
||||
}
|
||||
else if (this.pointer8 && this.pointer8.active == false)
|
||||
{
|
||||
return this.pointer8.start(event);
|
||||
}
|
||||
else if (this.pointer9 && this.pointer9.active == false)
|
||||
{
|
||||
return this.pointer9.start(event);
|
||||
}
|
||||
else if (this.pointer10 && this.pointer10.active == false)
|
||||
{
|
||||
return this.pointer10.start(event);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the matching Pointer object, passing in the event data.
|
||||
* @method updatePointer
|
||||
* @param {Any} event The event data from the Touch event
|
||||
* @return {Pointer} The Pointer object that was updated or null if no Pointer object is available
|
||||
**/
|
||||
public updatePointer(event): Pointer {
|
||||
|
||||
// Unrolled for speed
|
||||
if (this.pointer1.active == true && this.pointer1.identifier == event.identifier)
|
||||
{
|
||||
return this.pointer1.move(event);
|
||||
}
|
||||
else if (this.pointer2.active == true && this.pointer2.identifier == event.identifier)
|
||||
{
|
||||
return this.pointer2.move(event);
|
||||
}
|
||||
else if (this.pointer3.active == true && this.pointer3.identifier == event.identifier)
|
||||
{
|
||||
return this.pointer3.move(event);
|
||||
}
|
||||
else if (this.pointer4.active == true && this.pointer4.identifier == event.identifier)
|
||||
{
|
||||
return this.pointer4.move(event);
|
||||
}
|
||||
else if (this.pointer5.active == true && this.pointer5.identifier == event.identifier)
|
||||
{
|
||||
return this.pointer5.move(event);
|
||||
}
|
||||
else if (this.pointer6 && this.pointer6.active == true && this.pointer6.identifier == event.identifier)
|
||||
{
|
||||
return this.pointer6.move(event);
|
||||
}
|
||||
else if (this.pointer7 && this.pointer7.active == true && this.pointer7.identifier == event.identifier)
|
||||
{
|
||||
return this.pointer7.move(event);
|
||||
}
|
||||
else if (this.pointer8 && this.pointer8.active == true && this.pointer8.identifier == event.identifier)
|
||||
{
|
||||
return this.pointer8.move(event);
|
||||
}
|
||||
else if (this.pointer9 && this.pointer9.active == true && this.pointer9.identifier == event.identifier)
|
||||
{
|
||||
return this.pointer9.move(event);
|
||||
}
|
||||
else if (this.pointer10 && this.pointer10.active == true && this.pointer10.identifier == event.identifier)
|
||||
{
|
||||
return this.pointer10.move(event);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops the matching Pointer object, passing in the event data.
|
||||
* @method stopPointer
|
||||
* @param {Any} event The event data from the Touch event
|
||||
* @return {Pointer} The Pointer object that was stopped or null if no Pointer object is available
|
||||
**/
|
||||
public stopPointer(event): Pointer {
|
||||
|
||||
// Unrolled for speed
|
||||
if (this.pointer1.active == true && this.pointer1.identifier == event.identifier)
|
||||
{
|
||||
return this.pointer1.stop(event);
|
||||
}
|
||||
else if (this.pointer2.active == true && this.pointer2.identifier == event.identifier)
|
||||
{
|
||||
return this.pointer2.stop(event);
|
||||
}
|
||||
else if (this.pointer3.active == true && this.pointer3.identifier == event.identifier)
|
||||
{
|
||||
return this.pointer3.stop(event);
|
||||
}
|
||||
else if (this.pointer4.active == true && this.pointer4.identifier == event.identifier)
|
||||
{
|
||||
return this.pointer4.stop(event);
|
||||
}
|
||||
else if (this.pointer5.active == true && this.pointer5.identifier == event.identifier)
|
||||
{
|
||||
return this.pointer5.stop(event);
|
||||
}
|
||||
else if (this.pointer6 && this.pointer6.active == true && this.pointer6.identifier == event.identifier)
|
||||
{
|
||||
return this.pointer6.stop(event);
|
||||
}
|
||||
else if (this.pointer7 && this.pointer7.active == true && this.pointer7.identifier == event.identifier)
|
||||
{
|
||||
return this.pointer7.stop(event);
|
||||
}
|
||||
else if (this.pointer8 && this.pointer8.active == true && this.pointer8.identifier == event.identifier)
|
||||
{
|
||||
return this.pointer8.stop(event);
|
||||
}
|
||||
else if (this.pointer9 && this.pointer9.active == true && this.pointer9.identifier == event.identifier)
|
||||
{
|
||||
return this.pointer9.stop(event);
|
||||
}
|
||||
else if (this.pointer10 && this.pointer10.active == true && this.pointer10.identifier == event.identifier)
|
||||
{
|
||||
return this.pointer10.stop(event);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the next Pointer object whos active property matches the given state
|
||||
* @method getPointer
|
||||
* @param {Boolean} state The state the Pointer should be in (false for inactive, true for active)
|
||||
* @return {Pointer} A Pointer object or null if no Pointer object matches the requested state.
|
||||
**/
|
||||
public getPointer(state: bool = false): Pointer {
|
||||
|
||||
// Unrolled for speed
|
||||
if (this.pointer1.active == state)
|
||||
{
|
||||
return this.pointer1;
|
||||
}
|
||||
else if (this.pointer2.active == state)
|
||||
{
|
||||
return this.pointer2;
|
||||
}
|
||||
else if (this.pointer3.active == state)
|
||||
{
|
||||
return this.pointer3;
|
||||
}
|
||||
else if (this.pointer4.active == state)
|
||||
{
|
||||
return this.pointer4;
|
||||
}
|
||||
else if (this.pointer5.active == state)
|
||||
{
|
||||
return this.pointer5;
|
||||
}
|
||||
else if (this.pointer6 && this.pointer6.active == state)
|
||||
{
|
||||
return this.pointer6;
|
||||
}
|
||||
else if (this.pointer7 && this.pointer7.active == state)
|
||||
{
|
||||
return this.pointer7;
|
||||
}
|
||||
else if (this.pointer8 && this.pointer8.active == state)
|
||||
{
|
||||
return this.pointer8;
|
||||
}
|
||||
else if (this.pointer9 && this.pointer9.active == state)
|
||||
{
|
||||
return this.pointer9;
|
||||
}
|
||||
else if (this.pointer10 && this.pointer10.active == state)
|
||||
{
|
||||
return this.pointer10;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Pointer object whos identified property matches the given identifier value
|
||||
* @method getPointerFromIdentifier
|
||||
* @param {Number} identifier The Pointer.identifier value to search for
|
||||
* @return {Pointer} A Pointer object or null if no Pointer object matches the requested identifier.
|
||||
**/
|
||||
public getPointerFromIdentifier(identifier: number): Pointer {
|
||||
|
||||
// Unrolled for speed
|
||||
if (this.pointer1.identifier == identifier)
|
||||
{
|
||||
return this.pointer1;
|
||||
}
|
||||
else if (this.pointer2.identifier == identifier)
|
||||
{
|
||||
return this.pointer2;
|
||||
}
|
||||
else if (this.pointer3.identifier == identifier)
|
||||
{
|
||||
return this.pointer3;
|
||||
}
|
||||
else if (this.pointer4.identifier == identifier)
|
||||
{
|
||||
return this.pointer4;
|
||||
}
|
||||
else if (this.pointer5.identifier == identifier)
|
||||
{
|
||||
return this.pointer5;
|
||||
}
|
||||
else if (this.pointer6 && this.pointer6.identifier == identifier)
|
||||
{
|
||||
return this.pointer6;
|
||||
}
|
||||
else if (this.pointer7 && this.pointer7.identifier == identifier)
|
||||
{
|
||||
return this.pointer7;
|
||||
}
|
||||
else if (this.pointer8 && this.pointer8.identifier == identifier)
|
||||
{
|
||||
return this.pointer8;
|
||||
}
|
||||
else if (this.pointer9 && this.pointer9.identifier == identifier)
|
||||
{
|
||||
return this.pointer9;
|
||||
}
|
||||
else if (this.pointer10 && this.pointer10.identifier == identifier)
|
||||
{
|
||||
return this.pointer10;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Camera} [camera]
|
||||
*/
|
||||
public getWorldX(camera?: Camera = this.game.camera) {
|
||||
return camera.worldView.x + this.x;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Camera} [camera]
|
||||
*/
|
||||
public getWorldY(camera?: Camera = this.game.camera) {
|
||||
return camera.worldView.y + this.y;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Number} x
|
||||
* @param {Number} y
|
||||
* @param {String} [color]
|
||||
*/
|
||||
public renderDebugInfo(x: number, y: number, color?: string = 'rgb(255,255,255)') {
|
||||
|
||||
this.game.stage.context.fillStyle = color;
|
||||
this.game.stage.context.fillText('Input', x, y);
|
||||
this.game.stage.context.fillText('X: ' + this.x + ' Y: ' + this.y, x, y + 14);
|
||||
this.game.stage.context.fillText('World X: ' + this.getWorldX() + ' World Y: ' + this.getWorldY(), x, y + 28);
|
||||
this.game.stage.context.fillText('Scale X: ' + this.scale.x.toFixed(1) + ' Scale Y: ' + this.scale.x.toFixed(1), x, y + 42);
|
||||
this.game.stage.context.fillText('Screen X: ' + this.activePointer.screenX + ' Screen Y: ' + this.activePointer.screenY, x, y + 56);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the distance between two Pointer objects
|
||||
* @method getDistance
|
||||
* @param {Pointer} pointer1
|
||||
* @param {Pointer} pointer2
|
||||
**/
|
||||
public getDistance(pointer1: Pointer, pointer2: Pointer): number {
|
||||
return Vec2Utils.distance(pointer1.position, pointer2.position);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the angle between two Pointer objects
|
||||
* @method getAngle
|
||||
* @param {Pointer} pointer1
|
||||
* @param {Pointer} pointer2
|
||||
**/
|
||||
public getAngle(pointer1: Pointer, pointer2: Pointer): number {
|
||||
return Vec2Utils.angle(pointer1.position, pointer2.position);
|
||||
}
|
||||
|
||||
public pixelPerfectCheck(sprite: Phaser.Sprite, pointer: Phaser.Pointer, alpha: number = 255): bool {
|
||||
|
||||
this.hitContext.clearRect(0, 0, 1, 1);
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+12
-6
@@ -331,7 +331,7 @@ module Phaser {
|
||||
// x and y are the old values here?
|
||||
this.positionDown.setTo(this.x, this.y);
|
||||
|
||||
if (this.game.input.multiInputOverride == Input.MOUSE_OVERRIDES_TOUCH || this.game.input.multiInputOverride == Input.MOUSE_TOUCH_COMBINE || (this.game.input.multiInputOverride == Input.TOUCH_OVERRIDES_MOUSE && this.game.input.currentPointers == 0))
|
||||
if (this.game.input.multiInputOverride == InputManager.MOUSE_OVERRIDES_TOUCH || this.game.input.multiInputOverride == InputManager.MOUSE_TOUCH_COMBINE || (this.game.input.multiInputOverride == InputManager.TOUCH_OVERRIDES_MOUSE && this.game.input.currentPointers == 0))
|
||||
{
|
||||
//this.game.input.x = this.x * this.game.input.scale.x;
|
||||
//this.game.input.y = this.y * this.game.input.scale.y;
|
||||
@@ -365,7 +365,7 @@ module Phaser {
|
||||
{
|
||||
if (this._holdSent == false && this.duration >= this.game.input.holdRate)
|
||||
{
|
||||
if (this.game.input.multiInputOverride == Input.MOUSE_OVERRIDES_TOUCH || this.game.input.multiInputOverride == Input.MOUSE_TOUCH_COMBINE || (this.game.input.multiInputOverride == Input.TOUCH_OVERRIDES_MOUSE && this.game.input.currentPointers == 0))
|
||||
if (this.game.input.multiInputOverride == InputManager.MOUSE_OVERRIDES_TOUCH || this.game.input.multiInputOverride == InputManager.MOUSE_TOUCH_COMBINE || (this.game.input.multiInputOverride == InputManager.TOUCH_OVERRIDES_MOUSE && this.game.input.currentPointers == 0))
|
||||
{
|
||||
this.game.input.onHold.dispatch(this);
|
||||
}
|
||||
@@ -415,7 +415,7 @@ module Phaser {
|
||||
this.circle.x = this.x;
|
||||
this.circle.y = this.y;
|
||||
|
||||
if (this.game.input.multiInputOverride == Input.MOUSE_OVERRIDES_TOUCH || this.game.input.multiInputOverride == Input.MOUSE_TOUCH_COMBINE || (this.game.input.multiInputOverride == Input.TOUCH_OVERRIDES_MOUSE && this.game.input.currentPointers == 0))
|
||||
if (this.game.input.multiInputOverride == InputManager.MOUSE_OVERRIDES_TOUCH || this.game.input.multiInputOverride == InputManager.MOUSE_TOUCH_COMBINE || (this.game.input.multiInputOverride == InputManager.TOUCH_OVERRIDES_MOUSE && this.game.input.currentPointers == 0))
|
||||
{
|
||||
this.game.input.activePointer = this;
|
||||
this.game.input.x = this.x;
|
||||
@@ -425,6 +425,12 @@ module Phaser {
|
||||
this.game.input.circle.y = this.game.input.y;
|
||||
}
|
||||
|
||||
// If the game is paused we don't process any target objects
|
||||
if (this.game.paused)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
// Easy out if we're dragging something and it still exists
|
||||
if (this.targetObject !== null && this.targetObject.input && this.targetObject.input.isDragged == true)
|
||||
{
|
||||
@@ -444,7 +450,7 @@ module Phaser {
|
||||
{
|
||||
if (this.game.input.inputObjects[i] && this.game.input.inputObjects[i].input && this.game.input.inputObjects[i].input.checkPointerOver(this))
|
||||
{
|
||||
// If the object has a higher Input.PriorityID OR if the priority ID is the same as the current highest AND it has a higher renderOrderID, then set it to the top
|
||||
// If the object has a higher InputManager.PriorityID OR if the priority ID is the same as the current highest AND it has a higher renderOrderID, then set it to the top
|
||||
if (this.game.input.inputObjects[i].input.priorityID > this._highestInputPriorityID || (this.game.input.inputObjects[i].input.priorityID == this._highestInputPriorityID && this.game.input.inputObjects[i].renderOrderID > this._highestRenderOrderID))
|
||||
{
|
||||
this._highestRenderOrderID = this.game.input.inputObjects[i].renderOrderID;
|
||||
@@ -525,7 +531,7 @@ module Phaser {
|
||||
|
||||
this.timeUp = this.game.time.now;
|
||||
|
||||
if (this.game.input.multiInputOverride == Input.MOUSE_OVERRIDES_TOUCH || this.game.input.multiInputOverride == Input.MOUSE_TOUCH_COMBINE || (this.game.input.multiInputOverride == Input.TOUCH_OVERRIDES_MOUSE && this.game.input.currentPointers == 0))
|
||||
if (this.game.input.multiInputOverride == InputManager.MOUSE_OVERRIDES_TOUCH || this.game.input.multiInputOverride == InputManager.MOUSE_TOUCH_COMBINE || (this.game.input.multiInputOverride == InputManager.TOUCH_OVERRIDES_MOUSE && this.game.input.currentPointers == 0))
|
||||
{
|
||||
this.game.input.onUp.dispatch(this);
|
||||
|
||||
@@ -622,7 +628,7 @@ module Phaser {
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the Pointer properties. Called by Input.reset when you perform a State change.
|
||||
* Resets the Pointer properties. Called by InputManager.reset when you perform a State change.
|
||||
* @method reset
|
||||
*/
|
||||
public reset() {
|
||||
|
||||
+9
-72
@@ -12,17 +12,13 @@ module Phaser {
|
||||
export class GameMath {
|
||||
|
||||
constructor(game: Game) {
|
||||
|
||||
|
||||
this.game = game;
|
||||
|
||||
GameMath.sinA = [];
|
||||
GameMath.cosA = [];
|
||||
|
||||
// Android 4 stock browser bug fix
|
||||
GameMath.sinA.push(0);
|
||||
GameMath.cosA.push(0);
|
||||
|
||||
for (var i = 1; i < 360; i++)
|
||||
for (var i = 0; i < 360; i++)
|
||||
{
|
||||
GameMath.sinA.push(Math.sin(this.degreesToRadians(i)));
|
||||
GameMath.cosA.push(Math.cos(this.degreesToRadians(i)));
|
||||
@@ -841,34 +837,6 @@ module Phaser {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The global random number generator seed (for deterministic behavior in recordings and saves).
|
||||
*/
|
||||
public globalSeed: number = Math.random();
|
||||
|
||||
/**
|
||||
* Generates a random number. Deterministic, meaning safe
|
||||
* to use if you want to record replays in random environments.
|
||||
*
|
||||
* @return A <code>Number</code> between 0 and 1.
|
||||
*/
|
||||
public random(): number {
|
||||
return this.globalSeed = this.srand(this.globalSeed);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a random number based on the seed provided.
|
||||
*
|
||||
* @param Seed A number between 0 and 1, used to generate a predictable random number (very optional).
|
||||
*
|
||||
* @return A <code>Number</code> between 0 and 1.
|
||||
*/
|
||||
public srand(Seed: number): number {
|
||||
|
||||
return ((69621 * (Seed * 0x7FFFFFFF)) % 0x7FFFFFFF) / 0x7FFFFFFF;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a random entry from the given array.
|
||||
* Will return null if random selection is missing, or array has no entries.
|
||||
@@ -907,9 +875,9 @@ module Phaser {
|
||||
*
|
||||
* @return The rounded value of that number.
|
||||
*/
|
||||
public floor(Value: number): number {
|
||||
var n: number = Value | 0;
|
||||
return (Value > 0) ? (n) : ((n != Value) ? (n - 1) : (n));
|
||||
public floor(value: number): number {
|
||||
var n: number = value | 0;
|
||||
return (value > 0) ? (n) : ((n != value) ? (n - 1) : (n));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -919,9 +887,9 @@ module Phaser {
|
||||
*
|
||||
* @return The rounded value of that number.
|
||||
*/
|
||||
public ceil(Value: number): number {
|
||||
var n: number = Value | 0;
|
||||
return (Value > 0) ? ((n != Value) ? (n + 1) : (n)) : (n);
|
||||
public ceil(value: number): number {
|
||||
var n: number = value | 0;
|
||||
return (value > 0) ? ((n != value) ? (n + 1) : (n)) : (n);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1035,41 +1003,10 @@ module Phaser {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public vectorLength(dx:number, dy:number):number
|
||||
{
|
||||
public vectorLength(dx: number, dy: number): number {
|
||||
return Math.sqrt(dx * dx + dy * dy);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rotates the point around the x/y coordinates given to the desired rotation and distance
|
||||
* @param point {Object} Any object with exposed x and y properties
|
||||
* @param x {number} The x coordinate of the anchor point
|
||||
* @param y {number} The y coordinate of the anchor point
|
||||
* @param {Number} rotation The rotation in radians (unless asDegrees is true) to return the point from.
|
||||
* @param {Boolean} asDegrees Is the given rotation in radians (false) or degrees (true)?
|
||||
* @param {Number} distance An optional distance constraint between the point and the anchor
|
||||
* @return The modified point object
|
||||
*/
|
||||
public rotatePoint(point, x1: number, y1: number, rotation: number, asDegrees: bool = false, distance?:number = null) {
|
||||
|
||||
if (asDegrees)
|
||||
{
|
||||
rotation = rotation * GameMath.DEG_TO_RAD;
|
||||
}
|
||||
|
||||
// Get distance from origin to the point
|
||||
if (distance === null)
|
||||
{
|
||||
distance = Math.sqrt(((x1 - point.x) * (x1 - point.x)) + ((y1 - point.y) * (y1 - point.y)));
|
||||
}
|
||||
|
||||
point.x = x1 + distance * Math.cos(rotation);
|
||||
point.y = y1 + distance * Math.sin(rotation);
|
||||
|
||||
return point;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
/// <reference path="../Game.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - IntersectResult
|
||||
*
|
||||
* A light-weight result object to hold the results of an intersection. For when you need more than just true/false.
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class IntersectResult {
|
||||
|
||||
/**
|
||||
* Did they intersect or not?
|
||||
* @property result
|
||||
* @type {Boolean}
|
||||
*/
|
||||
result: bool = false;
|
||||
|
||||
/**
|
||||
* @property x
|
||||
* @type {Number}
|
||||
*/
|
||||
x: number;
|
||||
|
||||
/**
|
||||
* @property y
|
||||
* @type {Number}
|
||||
*/
|
||||
y: number;
|
||||
|
||||
/**
|
||||
* @property x1
|
||||
* @type {Number}
|
||||
*/
|
||||
x1: number;
|
||||
|
||||
/**
|
||||
* @property y1
|
||||
* @type {Number}
|
||||
*/
|
||||
y1: number;
|
||||
|
||||
/**
|
||||
* @property x2
|
||||
* @type {Number}
|
||||
*/
|
||||
x2: number;
|
||||
|
||||
/**
|
||||
* @property y2
|
||||
* @type {Number}
|
||||
*/
|
||||
y2: number;
|
||||
|
||||
/**
|
||||
* @property width
|
||||
* @type {Number}
|
||||
*/
|
||||
width: number;
|
||||
|
||||
/**
|
||||
* @property height
|
||||
* @type {Number}
|
||||
*/
|
||||
height: number;
|
||||
|
||||
/**
|
||||
*
|
||||
* @method setTo
|
||||
* @param {Number} x1
|
||||
* @param {Number} y1
|
||||
* @param {Number} [x2]
|
||||
* @param {Number} [y2]
|
||||
* @param {Number} [width]
|
||||
* @param {Number} [height]
|
||||
*/
|
||||
setTo(x1: number, y1: number, x2?: number = 0, y2?: number = 0, width?: number = 0, height?: number = 0) {
|
||||
|
||||
this.x = x1;
|
||||
this.y = y1;
|
||||
|
||||
this.x1 = x1;
|
||||
this.y1 = y1;
|
||||
|
||||
this.x2 = x2;
|
||||
this.y2 = y2;
|
||||
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
/// <reference path="../Game.ts" />
|
||||
/// <reference path="../core/Group.ts" />
|
||||
/// <reference path="Particle.ts" />
|
||||
/// <reference path="ArcadeParticle.ts" />
|
||||
/// <reference path="../utils/SpriteUtils.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Emitter
|
||||
* Phaser - ArcadeEmitter
|
||||
*
|
||||
* Emitter is a lightweight particle emitter. It can be used for one-time explosions or for
|
||||
* continuous effects like rain and fire. All it really does is launch Particle objects out
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class Emitter extends Group {
|
||||
export class ArcadeEmitter extends Group {
|
||||
|
||||
/**
|
||||
* Creates a new <code>Emitter</code> object at a specific position.
|
||||
@@ -191,7 +191,7 @@ module Phaser {
|
||||
*
|
||||
* @return This Emitter instance (nice for chaining stuff together, if you're into that).
|
||||
*/
|
||||
public makeParticles(graphics, quantity: number = 50, multiple: bool = false, collide: number = 0): Emitter {
|
||||
public makeParticles(graphics, quantity: number = 50, multiple: bool = false, collide: number = 0): ArcadeEmitter {
|
||||
|
||||
this.maxSize = quantity;
|
||||
|
||||
@@ -208,14 +208,14 @@ module Phaser {
|
||||
*/
|
||||
|
||||
var randomFrame: number;
|
||||
var particle: Particle;
|
||||
var particle: ArcadeParticle;
|
||||
var i: number = 0;
|
||||
|
||||
while (i < quantity)
|
||||
{
|
||||
if (this.particleClass == null)
|
||||
{
|
||||
particle = new Particle(this.game);
|
||||
particle = new ArcadeParticle(this.game);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -360,16 +360,16 @@ module Phaser {
|
||||
*/
|
||||
public emitParticle() {
|
||||
|
||||
var particle: Particle = this.recycle(Particle);
|
||||
var particle: ArcadeParticle = this.recycle(ArcadeParticle);
|
||||
|
||||
particle.lifespan = this.lifespan;
|
||||
//particle.body.bounce.setTo(this.bounce, this.bounce);
|
||||
SpriteUtils.reset(particle, this.x - (particle.width >> 1) + this.game.math.random() * this.width, this.y - (particle.height >> 1) + this.game.math.random() * this.height);
|
||||
SpriteUtils.reset(particle, this.x - (particle.width >> 1) + this.game.rnd.integer * this.width, this.y - (particle.height >> 1) + this.game.rnd.integer * this.height);
|
||||
particle.visible = true;
|
||||
|
||||
if (this.minParticleSpeed.x != this.maxParticleSpeed.x)
|
||||
{
|
||||
particle.body.velocity.x = this.minParticleSpeed.x + this.game.math.random() * (this.maxParticleSpeed.x - this.minParticleSpeed.x);
|
||||
particle.body.velocity.x = this.minParticleSpeed.x + this.game.rnd.integer * (this.maxParticleSpeed.x - this.minParticleSpeed.x);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -378,7 +378,7 @@ module Phaser {
|
||||
|
||||
if (this.minParticleSpeed.y != this.maxParticleSpeed.y)
|
||||
{
|
||||
particle.body.velocity.y = this.minParticleSpeed.y + this.game.math.random() * (this.maxParticleSpeed.y - this.minParticleSpeed.y);
|
||||
particle.body.velocity.y = this.minParticleSpeed.y + this.game.rnd.integer * (this.maxParticleSpeed.y - this.minParticleSpeed.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -389,7 +389,7 @@ module Phaser {
|
||||
|
||||
if (this.minRotation != this.maxRotation && this.minRotation !== 0 && this.maxRotation !== 0)
|
||||
{
|
||||
particle.body.angularVelocity = this.minRotation + this.game.math.random() * (this.maxRotation - this.minRotation);
|
||||
particle.body.angularVelocity = this.minRotation + this.game.rnd.integer * (this.maxRotation - this.minRotation);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -398,7 +398,7 @@ module Phaser {
|
||||
|
||||
if (particle.body.angularVelocity != 0)
|
||||
{
|
||||
particle.rotation = this.game.math.random() * 360 - 180;
|
||||
particle.rotation = this.game.rnd.integer * 360 - 180;
|
||||
}
|
||||
|
||||
//particle.body.drag.x = this.particleDrag.x;
|
||||
@@ -1,8 +1,8 @@
|
||||
/// <reference path="../Game.ts" />
|
||||
/// <reference path="Sprite.ts" />
|
||||
/// <reference path="../gameobjects/Sprite.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Particle
|
||||
* Phaser - ArcadeParticle
|
||||
*
|
||||
* This is a simple particle class that extends a Sprite to have a slightly more
|
||||
* specialised behaviour. It is used exclusively by the Emitter class and can be extended as required.
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class Particle extends Sprite {
|
||||
export class ArcadeParticle extends Sprite {
|
||||
|
||||
/**
|
||||
* Instantiate a new particle. Like <code>Sprite</code>, all meaningful creation
|
||||
@@ -17,4 +17,5 @@
|
||||
var Phaser;
|
||||
(function (Phaser) {
|
||||
Phaser.VERSION = 'Phaser version 1.0.0';
|
||||
Phaser.GAMES = [];
|
||||
})(Phaser || (Phaser = {}));
|
||||
|
||||
@@ -253,6 +253,8 @@ module Phaser {
|
||||
return false;
|
||||
}
|
||||
|
||||
camera.plugins.preRender();
|
||||
|
||||
// Reset our temp vars
|
||||
this._ga = -1;
|
||||
this._sx = 0;
|
||||
@@ -350,8 +352,6 @@ module Phaser {
|
||||
camera.texture.context.fillRect(this._dx, this._dy, this._dw, this._dh);
|
||||
}
|
||||
|
||||
camera.fx.preRender(camera);
|
||||
|
||||
if (camera.texture.loaded)
|
||||
{
|
||||
camera.texture.context.drawImage(
|
||||
@@ -367,14 +367,14 @@ module Phaser {
|
||||
);
|
||||
}
|
||||
|
||||
camera.plugins.render();
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
public postRenderCamera(camera: Camera) {
|
||||
|
||||
camera.fx.postRender(camera);
|
||||
|
||||
if (camera.modified || camera.texture.globalCompositeOperation)
|
||||
{
|
||||
camera.texture.context.restore();
|
||||
@@ -386,6 +386,8 @@ module Phaser {
|
||||
camera.texture.context.globalAlpha = this._ga;
|
||||
}
|
||||
|
||||
camera.plugins.postRender();
|
||||
|
||||
}
|
||||
|
||||
public renderCircle(camera: Camera, circle: Circle, context, outline?: bool = false, fill?: bool = true, lineColor?: string = 'rgb(0,255,0)', fillColor?: string = 'rgba(0,100,0.0.3)', lineWidth?: number = 1): bool {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/// <reference path="../Game.ts" />
|
||||
/// <reference path="../components/TilemapLayer.ts" />
|
||||
/// <reference path="../components/Tile.ts" />
|
||||
/// <reference path="TilemapLayer.ts" />
|
||||
/// <reference path="Tile.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Tilemap
|
||||
@@ -39,8 +39,8 @@ module Phaser {
|
||||
this.group = null;
|
||||
this.name = '';
|
||||
|
||||
this.texture = new Phaser.Components.Texture(this);
|
||||
this.transform = new Phaser.Components.Transform(this);
|
||||
this.texture = new Phaser.Display.Texture(this);
|
||||
this.transform = new Phaser.Components.TransformManager(this);
|
||||
|
||||
this.tiles = [];
|
||||
this.layers = [];
|
||||
@@ -110,17 +110,12 @@ module Phaser {
|
||||
/**
|
||||
* The texture used to render the Sprite.
|
||||
*/
|
||||
public texture: Phaser.Components.Texture;
|
||||
public texture: Phaser.Display.Texture;
|
||||
|
||||
/**
|
||||
* The Sprite transform component.
|
||||
*/
|
||||
public transform: Phaser.Components.Transform;
|
||||
|
||||
/**
|
||||
* The Input component
|
||||
*/
|
||||
//public input: Phaser.Components.Sprite.Input;
|
||||
public transform: Phaser.Components.TransformManager;
|
||||
|
||||
/**
|
||||
* The Events component
|
||||
@@ -1,5 +1,5 @@
|
||||
/// <reference path="../Game.ts" />
|
||||
/// <reference path="../gameobjects/Tilemap.ts" />
|
||||
/// <reference path="Tilemap.ts" />
|
||||
/// <reference path="../gameobjects/IGameObject.ts" />
|
||||
|
||||
/**
|
||||
@@ -35,8 +35,8 @@ module Phaser {
|
||||
this.tileHeight = tileHeight;
|
||||
this.boundsInTiles = new Rectangle();
|
||||
|
||||
this.texture = new Phaser.Components.Texture(this);
|
||||
this.transform = new Phaser.Components.Transform(this);
|
||||
this.texture = new Phaser.Display.Texture(this);
|
||||
this.transform = new Phaser.Components.TransformManager(this);
|
||||
|
||||
if (key !== null)
|
||||
{
|
||||
@@ -77,12 +77,12 @@ module Phaser {
|
||||
/**
|
||||
* The texture used to render the Sprite.
|
||||
*/
|
||||
public texture: Phaser.Components.Texture;
|
||||
public texture: Phaser.Display.Texture;
|
||||
|
||||
/**
|
||||
* The Sprite transform component.
|
||||
*/
|
||||
public transform: Phaser.Components.Transform;
|
||||
public transform: Phaser.Components.TransformManager;
|
||||
|
||||
public tileOffsets;
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/// <reference path="Game.ts" />
|
||||
/// <reference path="../Game.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Time
|
||||
* Phaser - TimeManager
|
||||
*
|
||||
* This is the game clock and it manages elapsed time and calculation of delta values, used for game object motion.
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class Time {
|
||||
export class TimeManager {
|
||||
|
||||
/**
|
||||
* Time constructor
|
||||
@@ -18,17 +18,18 @@ module Phaser {
|
||||
*/
|
||||
constructor(game: Game) {
|
||||
|
||||
this.game = game;
|
||||
|
||||
this._started = 0;
|
||||
this._timeLastSecond = this._started;
|
||||
this.time = this._started;
|
||||
this._game = game;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Local private reference to game.
|
||||
* Local reference to game.
|
||||
*/
|
||||
private _game: Game;
|
||||
public game: Game;
|
||||
|
||||
/**
|
||||
* Time when this object created.
|
||||
@@ -1,17 +1,17 @@
|
||||
/// <reference path="../Game.ts" />
|
||||
/// <reference path="../math/Vec2.ts" />
|
||||
/// <reference path="../geom/Rectangle.ts" />
|
||||
/// <reference path="../components/animation/AnimationManager.ts" />
|
||||
/// <reference path="../components/Texture.ts" />
|
||||
/// <reference path="../components/Transform.ts" />
|
||||
/// <reference path="../components/sprite/Input.ts" />
|
||||
/// <reference path="../components/sprite/Events.ts" />
|
||||
/// <reference path="../animation/AnimationManager.ts" />
|
||||
/// <reference path="../input/InputHandler.ts" />
|
||||
/// <reference path="../display/Texture.ts" />
|
||||
/// <reference path="../gameobjects/TransformManager.ts" />
|
||||
/// <reference path="../gameobjects/Events.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Button
|
||||
* Phaser - UI - Button
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
module Phaser.UI {
|
||||
|
||||
export class Button extends Sprite {
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
var __extends = this.__extends || function (d, b) {
|
||||
function __() { this.constructor = d; }
|
||||
__.prototype = b.prototype;
|
||||
d.prototype = new __();
|
||||
};
|
||||
var Phaser;
|
||||
(function (Phaser) {
|
||||
(function (Plugins) {
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
/// <reference path="../../Phaser/core/Plugin.ts" />
|
||||
/**
|
||||
* Phaser - Plugins - Camera FX - Mirrir
|
||||
*
|
||||
* Give your game that classic retro feel!
|
||||
*/
|
||||
(function (CameraFX) {
|
||||
var Mirror = (function (_super) {
|
||||
__extends(Mirror, _super);
|
||||
function Mirror(game, parent) {
|
||||
_super.call(this, game, parent);
|
||||
this._mirrorColor = null;
|
||||
this.flipX = false;
|
||||
this.flipY = true;
|
||||
this.cls = false;
|
||||
this.camera = parent;
|
||||
this._canvas = document.createElement('canvas');
|
||||
this._canvas.width = parent.width;
|
||||
this._canvas.height = parent.height;
|
||||
this._context = this._canvas.getContext('2d');
|
||||
}
|
||||
Mirror.prototype.start = /**
|
||||
* This is the rectangular region to grab from the Camera used in the Mirror effect
|
||||
* It is rendered to the Stage at Mirror.x/y (note the use of Stage coordinates, not World coordinates)
|
||||
*/
|
||||
function (x, y, region, fillColor) {
|
||||
if (typeof fillColor === "undefined") { fillColor = 'rgba(0, 0, 100, 0.5)'; }
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this._mirrorX = region.x;
|
||||
this._mirrorY = region.y;
|
||||
this._mirrorWidth = region.width;
|
||||
this._mirrorHeight = region.height;
|
||||
if(fillColor) {
|
||||
this._mirrorColor = fillColor;
|
||||
this._context.fillStyle = this._mirrorColor;
|
||||
}
|
||||
};
|
||||
Mirror.prototype.postRender = function () {
|
||||
this._sx = this.camera.screenView.x + this._mirrorX;
|
||||
this._sy = this.camera.screenView.y + this._mirrorY;
|
||||
if(this.flipX == true && this.flipY == false) {
|
||||
this._sx = 0;
|
||||
} else if(this.flipY == true && this.flipX == false) {
|
||||
this._sy = 0;
|
||||
}
|
||||
this._context.drawImage(this.game.stage.canvas, this._sx, this._sy, this._mirrorWidth, this._mirrorHeight, 0, 0, this._mirrorWidth, this._mirrorHeight);
|
||||
if(this._mirrorColor) {
|
||||
this._context.fillRect(0, 0, this._mirrorWidth, this._mirrorHeight);
|
||||
}
|
||||
if(this.flipX || this.flipY) {
|
||||
this.game.stage.context.save();
|
||||
}
|
||||
if(this.flipX && this.flipY) {
|
||||
this.game.stage.context.transform(-1, 0, 0, -1, this._mirrorWidth, this._mirrorHeight);
|
||||
this.game.stage.context.drawImage(this._canvas, -this.x, -this.y);
|
||||
} else if(this.flipX) {
|
||||
this.game.stage.context.transform(-1, 0, 0, 1, this._mirrorWidth, 0);
|
||||
this.game.stage.context.drawImage(this._canvas, -this.x, this.y);
|
||||
} else if(this.flipY) {
|
||||
this.game.stage.context.transform(1, 0, 0, -1, 0, this._mirrorHeight);
|
||||
this.game.stage.context.drawImage(this._canvas, this.x, -this.y);
|
||||
}
|
||||
if(this.flipX || this.flipY) {
|
||||
this.game.stage.context.restore();
|
||||
}
|
||||
};
|
||||
return Mirror;
|
||||
})(Phaser.Plugin);
|
||||
CameraFX.Mirror = Mirror;
|
||||
})(Plugins.CameraFX || (Plugins.CameraFX = {}));
|
||||
var CameraFX = Plugins.CameraFX;
|
||||
})(Phaser.Plugins || (Phaser.Plugins = {}));
|
||||
var Plugins = Phaser.Plugins;
|
||||
})(Phaser || (Phaser = {}));
|
||||
@@ -0,0 +1,129 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
/// <reference path="../../Phaser/core/Plugin.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Plugins - Camera FX - Mirrir
|
||||
*
|
||||
* Give your game that classic retro feel!
|
||||
*/
|
||||
|
||||
module Phaser.Plugins.CameraFX {
|
||||
|
||||
export class Mirror extends Phaser.Plugin {
|
||||
|
||||
constructor(game: Phaser.Game, parent) {
|
||||
|
||||
super(game, parent);
|
||||
this.camera = parent;
|
||||
|
||||
this._canvas = <HTMLCanvasElement> document.createElement('canvas');
|
||||
this._canvas.width = parent.width;
|
||||
this._canvas.height = parent.height;
|
||||
this._context = this._canvas.getContext('2d');
|
||||
|
||||
}
|
||||
|
||||
private _canvas: HTMLCanvasElement;
|
||||
private _context: CanvasRenderingContext2D;
|
||||
|
||||
private _sx: number;
|
||||
private _sy: number;
|
||||
private _mirrorX: number;
|
||||
private _mirrorY: number;
|
||||
private _mirrorWidth: number;
|
||||
private _mirrorHeight: number;
|
||||
private _mirrorColor: string = null;
|
||||
|
||||
public camera: Phaser.Camera;
|
||||
|
||||
public flipX: bool = false;
|
||||
public flipY: bool = true;
|
||||
|
||||
public x: number;
|
||||
public y: number;
|
||||
public cls: bool = false;
|
||||
|
||||
/**
|
||||
* This is the rectangular region to grab from the Camera used in the Mirror effect
|
||||
* It is rendered to the Stage at Mirror.x/y (note the use of Stage coordinates, not World coordinates)
|
||||
*/
|
||||
public start(x: number, y: number, region: Phaser.Rectangle, fillColor?: string = 'rgba(0, 0, 100, 0.5)') {
|
||||
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
|
||||
this._mirrorX = region.x;
|
||||
this._mirrorY = region.y;
|
||||
this._mirrorWidth = region.width;
|
||||
this._mirrorHeight = region.height;
|
||||
|
||||
if (fillColor)
|
||||
{
|
||||
this._mirrorColor = fillColor;
|
||||
this._context.fillStyle = this._mirrorColor;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public postRender() {
|
||||
|
||||
this._sx = this.camera.screenView.x + this._mirrorX;
|
||||
this._sy = this.camera.screenView.y + this._mirrorY;
|
||||
|
||||
if (this.flipX == true && this.flipY == false)
|
||||
{
|
||||
this._sx = 0;
|
||||
}
|
||||
else if (this.flipY == true && this.flipX == false)
|
||||
{
|
||||
this._sy = 0;
|
||||
}
|
||||
|
||||
this._context.drawImage(
|
||||
this.game.stage.canvas,
|
||||
this._sx,
|
||||
this._sy,
|
||||
this._mirrorWidth,
|
||||
this._mirrorHeight,
|
||||
0,
|
||||
0,
|
||||
this._mirrorWidth,
|
||||
this._mirrorHeight
|
||||
);
|
||||
|
||||
if (this._mirrorColor)
|
||||
{
|
||||
this._context.fillRect(0, 0, this._mirrorWidth, this._mirrorHeight);
|
||||
}
|
||||
|
||||
if (this.flipX || this.flipY)
|
||||
{
|
||||
this.game.stage.context.save();
|
||||
}
|
||||
|
||||
if (this.flipX && this.flipY)
|
||||
{
|
||||
this.game.stage.context.transform(-1, 0, 0, -1, this._mirrorWidth, this._mirrorHeight);
|
||||
this.game.stage.context.drawImage(this._canvas, -this.x, -this.y);
|
||||
}
|
||||
else if (this.flipX)
|
||||
{
|
||||
this.game.stage.context.transform(-1, 0, 0, 1, this._mirrorWidth, 0);
|
||||
this.game.stage.context.drawImage(this._canvas, -this.x, this.y);
|
||||
}
|
||||
else if (this.flipY)
|
||||
{
|
||||
this.game.stage.context.transform(1, 0, 0, -1, 0, this._mirrorHeight);
|
||||
this.game.stage.context.drawImage(this._canvas, this.x, -this.y);
|
||||
}
|
||||
|
||||
if (this.flipX || this.flipY)
|
||||
{
|
||||
this.game.stage.context.restore();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
var __extends = this.__extends || function (d, b) {
|
||||
function __() { this.constructor = d; }
|
||||
__.prototype = b.prototype;
|
||||
d.prototype = new __();
|
||||
};
|
||||
var Phaser;
|
||||
(function (Phaser) {
|
||||
(function (Plugins) {
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
/// <reference path="../../Phaser/core/Plugin.ts" />
|
||||
/**
|
||||
* Phaser - Plugins - Camera FX - Scanlines
|
||||
*
|
||||
* Give your game that classic retro feel!
|
||||
*/
|
||||
(function (CameraFX) {
|
||||
var Scanlines = (function (_super) {
|
||||
__extends(Scanlines, _super);
|
||||
function Scanlines(game, parent) {
|
||||
_super.call(this, game, parent);
|
||||
this.spacing = 4;
|
||||
this.color = 'rgba(0, 0, 0, 0.3)';
|
||||
this.camera = parent;
|
||||
}
|
||||
Scanlines.prototype.postRender = function () {
|
||||
this.game.stage.context.fillStyle = this.color;
|
||||
for(var y = this.camera.screenView.y; y < this.camera.screenView.height; y += this.spacing) {
|
||||
this.game.stage.context.fillRect(this.camera.screenView.x, y, this.camera.screenView.width, 1);
|
||||
}
|
||||
};
|
||||
return Scanlines;
|
||||
})(Phaser.Plugin);
|
||||
CameraFX.Scanlines = Scanlines;
|
||||
})(Plugins.CameraFX || (Plugins.CameraFX = {}));
|
||||
var CameraFX = Plugins.CameraFX;
|
||||
})(Phaser.Plugins || (Phaser.Plugins = {}));
|
||||
var Plugins = Phaser.Plugins;
|
||||
})(Phaser || (Phaser = {}));
|
||||
@@ -0,0 +1,37 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
/// <reference path="../../Phaser/core/Plugin.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Plugins - Camera FX - Scanlines
|
||||
*
|
||||
* Give your game that classic retro feel!
|
||||
*/
|
||||
|
||||
module Phaser.Plugins.CameraFX {
|
||||
|
||||
export class Scanlines extends Phaser.Plugin {
|
||||
|
||||
constructor(game: Phaser.Game, parent) {
|
||||
|
||||
super(game, parent);
|
||||
this.camera = parent;
|
||||
|
||||
}
|
||||
|
||||
public spacing: number = 4;
|
||||
public color: string = 'rgba(0, 0, 0, 0.3)';
|
||||
public camera: Phaser.Camera;
|
||||
|
||||
public postRender() {
|
||||
|
||||
this.game.stage.context.fillStyle = this.color;
|
||||
|
||||
for (var y = this.camera.screenView.y; y < this.camera.screenView.height; y += this.spacing)
|
||||
{
|
||||
this.game.stage.context.fillRect(this.camera.screenView.x, y, this.camera.screenView.width, 1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
// Module
|
||||
var Shapes;
|
||||
(function (Shapes) {
|
||||
// Class
|
||||
var Point = (function () {
|
||||
// Constructor
|
||||
function Point(x, y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
Point.prototype.getDist = // Instance member
|
||||
function () {
|
||||
return Math.sqrt(this.x * this.x + this.y * this.y);
|
||||
};
|
||||
Point.origin = new Point(0, 0);
|
||||
return Point;
|
||||
})();
|
||||
Shapes.Point = Point;
|
||||
})(Shapes || (Shapes = {}));
|
||||
// Local variables
|
||||
var p = new Shapes.Point(3, 4);
|
||||
var dist = p.getDist();
|
||||
@@ -1,21 +0,0 @@
|
||||
/// <reference path="../Phaser/Game.ts" />
|
||||
|
||||
module Phaser {
|
||||
|
||||
export interface IPlugin {
|
||||
|
||||
game: Game;
|
||||
active: bool;
|
||||
visible: bool;
|
||||
|
||||
preUpdate();
|
||||
postUpdate();
|
||||
|
||||
preRender();
|
||||
postRender();
|
||||
|
||||
destroy();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -56,10 +56,14 @@
|
||||
<TypeScriptCompile Include="Template.ts" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="IPlugin.js">
|
||||
<DependentUpon>IPlugin.ts</DependentUpon>
|
||||
<TypeScriptCompile Include="CameraFX\Scanlines.ts" />
|
||||
<TypeScriptCompile Include="CameraFX\Mirror.ts" />
|
||||
<Content Include="CameraFX\Mirror.js">
|
||||
<DependentUpon>Mirror.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="CameraFX\Scanlines.js">
|
||||
<DependentUpon>Scanlines.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="IPlugin.ts" />
|
||||
<Content Include="Template.js">
|
||||
<DependentUpon>Template.ts</DependentUpon>
|
||||
</Content>
|
||||
|
||||
+29
-11
@@ -1,16 +1,28 @@
|
||||
var __extends = this.__extends || function (d, b) {
|
||||
function __() { this.constructor = d; }
|
||||
__.prototype = b.prototype;
|
||||
d.prototype = new __();
|
||||
};
|
||||
var Phaser;
|
||||
(function (Phaser) {
|
||||
/// <reference path="../Phaser/Game.ts" />
|
||||
/// <reference path="IPlugin.ts" />
|
||||
/// <reference path="../Phaser/core/Plugin.ts" />
|
||||
/**
|
||||
* Phaser - Example Plugin
|
||||
*/
|
||||
(function (Plugins) {
|
||||
var Example = (function () {
|
||||
function Example(game) {
|
||||
this.game = game;
|
||||
var Example = (function (_super) {
|
||||
__extends(Example, _super);
|
||||
function Example(game, parent) {
|
||||
_super.call(this, game, parent);
|
||||
this.active = true;
|
||||
this.visible = true;
|
||||
this.hasPreUpdate = false;
|
||||
this.hasUpdate = false;
|
||||
this.hasPostUpdate = false;
|
||||
this.hasPreRender = false;
|
||||
this.hasRender = false;
|
||||
this.hasPostRender = false;
|
||||
}
|
||||
Example.prototype.preUpdate = /**
|
||||
* Pre-update is called at the start of the update cycle, before any other updates have taken place.
|
||||
@@ -18,6 +30,12 @@ var Phaser;
|
||||
*/
|
||||
function () {
|
||||
};
|
||||
Example.prototype.update = /**
|
||||
* Pre-update is called at the start of the update cycle, after all the core system updates have taken place, but before the world update.
|
||||
* It is only called if active is set to true.
|
||||
*/
|
||||
function () {
|
||||
};
|
||||
Example.prototype.postUpdate = /**
|
||||
* Post-update is called at the end of the objects update cycle, after other update logic has taken place.
|
||||
* It is only called if active is set to true.
|
||||
@@ -30,20 +48,20 @@ var Phaser;
|
||||
*/
|
||||
function () {
|
||||
};
|
||||
Example.prototype.render = /**
|
||||
* Pre-render is called right before the Game Renderer starts and before any custom preRender callbacks have been run.
|
||||
* It is only called if visible is set to true.
|
||||
*/
|
||||
function () {
|
||||
};
|
||||
Example.prototype.postRender = /**
|
||||
* Post-render is called after every camera and game object has been rendered, also after any custom postRender callbacks have been run.
|
||||
* It is only called if visible is set to true.
|
||||
*/
|
||||
function () {
|
||||
};
|
||||
Example.prototype.destroy = /**
|
||||
* Clear down this Plugin and null out references
|
||||
*/
|
||||
function () {
|
||||
this.game = null;
|
||||
};
|
||||
return Example;
|
||||
})();
|
||||
})(Phaser.Plugin);
|
||||
Plugins.Example = Example;
|
||||
})(Phaser.Plugins || (Phaser.Plugins = {}));
|
||||
var Plugins = Phaser.Plugins;
|
||||
|
||||
+27
-25
@@ -1,5 +1,5 @@
|
||||
/// <reference path="../Phaser/Game.ts" />
|
||||
/// <reference path="IPlugin.ts" />
|
||||
/// <reference path="../Phaser/core/Plugin.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Example Plugin
|
||||
@@ -7,31 +7,25 @@
|
||||
|
||||
module Phaser.Plugins {
|
||||
|
||||
export class Example implements Phaser.IPlugin {
|
||||
export class Example extends Phaser.Plugin {
|
||||
|
||||
constructor(game: Phaser.Game) {
|
||||
constructor(game: Phaser.Game, parent) {
|
||||
|
||||
super(game, parent);
|
||||
|
||||
this.game = game;
|
||||
this.active = true;
|
||||
this.visible = true;
|
||||
|
||||
this.hasPreUpdate = false;
|
||||
this.hasUpdate = false;
|
||||
this.hasPostUpdate = false;
|
||||
|
||||
this.hasPreRender = false;
|
||||
this.hasRender = false;
|
||||
this.hasPostRender = false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The essential reference to the main game object.
|
||||
*/
|
||||
public game: Game;
|
||||
|
||||
/**
|
||||
* Controls whether preUpdate or postUpdate are called
|
||||
*/
|
||||
public active: bool;
|
||||
|
||||
/**
|
||||
* Controls whether preRender or postRender are called
|
||||
*/
|
||||
public visible: bool;
|
||||
|
||||
/**
|
||||
* Pre-update is called at the start of the update cycle, before any other updates have taken place.
|
||||
* It is only called if active is set to true.
|
||||
@@ -39,6 +33,13 @@ module Phaser.Plugins {
|
||||
public preUpdate() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Pre-update is called at the start of the update cycle, after all the core system updates have taken place, but before the world update.
|
||||
* It is only called if active is set to true.
|
||||
*/
|
||||
public update() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Post-update is called at the end of the objects update cycle, after other update logic has taken place.
|
||||
* It is only called if active is set to true.
|
||||
@@ -53,6 +54,13 @@ module Phaser.Plugins {
|
||||
public preRender() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Pre-render is called right before the Game Renderer starts and before any custom preRender callbacks have been run.
|
||||
* It is only called if visible is set to true.
|
||||
*/
|
||||
public render() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Post-render is called after every camera and game object has been rendered, also after any custom postRender callbacks have been run.
|
||||
* It is only called if visible is set to true.
|
||||
@@ -60,12 +68,6 @@ module Phaser.Plugins {
|
||||
public postRender() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear down this Plugin and null out references
|
||||
*/
|
||||
public destroy() {
|
||||
this.game = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ Latest Update
|
||||
|
||||
TODO:
|
||||
|
||||
* Dispatch world resize event
|
||||
* Investigate why tweens don't restart after the game pauses
|
||||
* Fix bug in Tween yoyo + loop combo
|
||||
* Check that tween pausing works with the new performance.now
|
||||
@@ -30,15 +29,12 @@ TODO:
|
||||
* Investigate bug re: tilemap collision and animation frames
|
||||
* Update tests that use arrow keys and include touch/mouse support (FlxControlHandler style)
|
||||
* Pointer.getWorldX(camera) needs to take camera scale into consideration
|
||||
* If stage.clear set to false and game pauses, when it unpauses you still see the pause arrow - resolve this
|
||||
* Add clip support + shape options to Texture Component.
|
||||
* Make sure I'm using Point and not Vec2 when it's not a directional vector I need
|
||||
* Drag Sprite with "snap to center" uses local coords not world, so fails on scrolling world (no center lock works fine)
|
||||
* Need to be able to set the current tilemap layer, then the getTileXY default layer uses that one if no other given
|
||||
* Pointer worldX/Y don't appear to be correct for some reason
|
||||
* Create a Pixel game object type (useful for particles / fx)
|
||||
* Sprite collision events
|
||||
* See which functions in the input component can move elsewhere (utils)
|
||||
* Move all of the renderDebugInfo methods to the DebugUtils class
|
||||
* Check bounds/edge points when sprite is only 1x1 sized :)
|
||||
* QuadTree.physics.checkHullIntersection
|
||||
@@ -52,16 +48,13 @@ TODO:
|
||||
* Stage CSS3 Transforms?
|
||||
* Ability to layer another DOM object and have it controlled by the game somehow. Can then do stacked canvas effects.
|
||||
* Stage lost to mute
|
||||
* When game is paused Pointer shouldn't process targetObjects / change cursor
|
||||
* Need to limit touch priority of items in groups?
|
||||
* Check if it works from an iFrame
|
||||
* Bitmap Font support
|
||||
* Basic Window component (maybe a propogating Group?)
|
||||
* Put ArcadePhysics back in
|
||||
* Look at the N+ tile support maybe with ArcadePhysics?
|
||||
* Pixel-perfect click check
|
||||
* Check Flash atlas export is supported
|
||||
* Plug-in Support
|
||||
* DynamicTexture.setPixel needs to be swapped for a proper pixel put, not the filledRect it currently is.
|
||||
|
||||
|
||||
@@ -166,7 +159,7 @@ V1.0.0
|
||||
* Added Stage.disableVisibilityChange to stop the auto pause/resume from ever firing.
|
||||
* Added crop support to the Texture component, so you can do Sprite.crop to restrict rendering to a specified Rectangle without distortion.
|
||||
* Added references to all the event listener functions so they can be cleanly destroyed.
|
||||
* Fixed interesting Firefox bug when an audio track ended it fired another 'canplaythrough' event, confusing the Loader.
|
||||
* Fixed interesting Firefox issue when an audio track ended it fired another 'canplaythrough' event, confusing the Loader.
|
||||
|
||||
|
||||
V0.9.6
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
audioSprite:
|
||||
Phaser.Sound
|
||||
button:
|
||||
Phaser.Button
|
||||
Phaser.UI.Button
|
||||
pause:
|
||||
Phaser.Button
|
||||
Phaser.UI.Button
|
||||
function create() {
|
||||
this.audioSprite = game.add.audio('rabbit');
|
||||
this.audioSprite.addMarker('title', 3.00, 5.00, 1, true);
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
}
|
||||
|
||||
audioSprite: Phaser.Sound;
|
||||
button: Phaser.Button;
|
||||
pause: Phaser.Button;
|
||||
button: Phaser.UI.Button;
|
||||
pause: Phaser.UI.Button;
|
||||
|
||||
function create() {
|
||||
|
||||
|
||||
@@ -13,15 +13,15 @@
|
||||
game.load.start();
|
||||
}
|
||||
button:
|
||||
Phaser.Button
|
||||
Phaser.UI.Button
|
||||
music:
|
||||
Phaser.Sound
|
||||
volumeUp:
|
||||
Phaser.Button
|
||||
Phaser.UI.Button
|
||||
volumeDown:
|
||||
Phaser.Button
|
||||
Phaser.UI.Button
|
||||
pause:
|
||||
Phaser.Button
|
||||
Phaser.UI.Button
|
||||
function create() {
|
||||
this.music = game.add.audio('boden');
|
||||
this.button = game.add.button(game.stage.centerX, 400, 'button', playMusic, this, 2, 1, 0);
|
||||
|
||||
@@ -17,11 +17,11 @@
|
||||
|
||||
}
|
||||
|
||||
button: Phaser.Button;
|
||||
button: Phaser.UI.Button;
|
||||
music: Phaser.Sound;
|
||||
volumeUp: Phaser.Button;
|
||||
volumeDown: Phaser.Button;
|
||||
pause: Phaser.Button;
|
||||
volumeUp: Phaser.UI.Button;
|
||||
volumeDown: Phaser.UI.Button;
|
||||
pause: Phaser.UI.Button;
|
||||
|
||||
function create() {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
/// <reference path="../../Phaser/gameobjects/Button.ts" />
|
||||
/// <reference path="../../Phaser/ui/Button.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, init, create);
|
||||
function init() {
|
||||
@@ -10,7 +10,7 @@
|
||||
image:
|
||||
Phaser.Sprite
|
||||
button:
|
||||
Phaser.Button
|
||||
Phaser.UI.Button
|
||||
function create() {
|
||||
// This is just an image that we'll toggle the display of when you click the button
|
||||
this.image = game.add.sprite(game.stage.centerX, 0, 'beast');
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
/// <reference path="../../Phaser/gameobjects/Button.ts" />
|
||||
/// <reference path="../../Phaser/ui/Button.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
}
|
||||
|
||||
image: Phaser.Sprite;
|
||||
button: Phaser.Button;
|
||||
button: Phaser.UI.Button;
|
||||
|
||||
function create() {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
/// <reference path="../../Phaser/gameobjects/Button.ts" />
|
||||
/// <reference path="../../Phaser/ui/Button.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, init, create);
|
||||
function init() {
|
||||
@@ -10,8 +10,9 @@
|
||||
image:
|
||||
Phaser.Sprite
|
||||
button:
|
||||
Phaser.Button
|
||||
Phaser.UI.Button
|
||||
function create() {
|
||||
game.stage.clear = false;
|
||||
// This is just an image that we'll toggle the display of when you click the button
|
||||
this.image = game.add.sprite(game.stage.centerX, 0, 'beast');
|
||||
this.image.transform.origin.setTo(0.5, 0);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
/// <reference path="../../Phaser/gameobjects/Button.ts" />
|
||||
/// <reference path="../../Phaser/ui/Button.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
}
|
||||
|
||||
image: Phaser.Sprite;
|
||||
button: Phaser.Button;
|
||||
button: Phaser.UI.Button;
|
||||
|
||||
function create() {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
/// <reference path="../../Phaser/gameobjects/Button.ts" />
|
||||
/// <reference path="../../Phaser/ui/Button.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
function init() {
|
||||
@@ -10,7 +10,7 @@
|
||||
image:
|
||||
Phaser.Sprite
|
||||
button:
|
||||
Phaser.Button
|
||||
Phaser.UI.Button
|
||||
function create() {
|
||||
// This is just an image that we'll toggle the display of when you click the button
|
||||
this.image = game.add.sprite(game.stage.centerX, 0, 'beast');
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
/// <reference path="../../Phaser/gameobjects/Button.ts" />
|
||||
/// <reference path="../../Phaser/ui/Button.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
}
|
||||
|
||||
image: Phaser.Sprite;
|
||||
button: Phaser.Button;
|
||||
button: Phaser.UI.Button;
|
||||
|
||||
function create() {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
/// <reference path="../../build/phaser-fx.d.ts" />
|
||||
/// <reference path="../../Plugins/CameraFX/Mirror.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
function init() {
|
||||
@@ -16,7 +16,7 @@
|
||||
// Because it's our default camera we need to tell it to disable clipping, otherwise we'll never see the mirror effect render.
|
||||
game.camera.disableClipping = true;
|
||||
// Add our effect to the camera
|
||||
mirror = game.camera.fx.add(Phaser.FX.Camera.Mirror);
|
||||
mirror = game.camera.plugins.add(Phaser.Plugins.CameraFX.Mirror);
|
||||
// The first 2 parameters are the x and y coordinates of where to display the effect. They are in STAGE coordinates, not World.
|
||||
// The next is a Rectangle making up the region of the Camera that we'll create the effect from (in this case the whole camera).
|
||||
// Finally we set the fill color that is put over the top of the mirror effect.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
/// <reference path="../../build/phaser-fx.d.ts" />
|
||||
/// <reference path="../../Plugins/CameraFX/Mirror.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
}
|
||||
|
||||
var mirror: Phaser.FX.Camera.Mirror;
|
||||
var mirror: Phaser.Plugins.CameraFX.Mirror;
|
||||
|
||||
function create() {
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
game.camera.disableClipping = true;
|
||||
|
||||
// Add our effect to the camera
|
||||
mirror = <Phaser.FX.Camera.Mirror> game.camera.fx.add(Phaser.FX.Camera.Mirror);
|
||||
mirror = <Phaser.Plugins.CameraFX.Mirror> game.camera.plugins.add(Phaser.Plugins.CameraFX.Mirror);
|
||||
|
||||
// The first 2 parameters are the x and y coordinates of where to display the effect. They are in STAGE coordinates, not World.
|
||||
// The next is a Rectangle making up the region of the Camera that we'll create the effect from (in this case the whole camera).
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
/// <reference path="../../build/phaser-fx.d.ts" />
|
||||
/// <reference path="../../Plugins/CameraFX/Scanlines.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
function init() {
|
||||
@@ -10,7 +10,7 @@
|
||||
function create() {
|
||||
game.world.setSize(1216, 896);
|
||||
// Add our effect to the camera
|
||||
scanlines = game.camera.fx.add(Phaser.FX.Camera.Scanlines);
|
||||
scanlines = game.camera.plugins.add(Phaser.Plugins.CameraFX.Scanlines);
|
||||
// We'll have the scanlines spaced out every 2 pixels
|
||||
scanlines.spacing = 2;
|
||||
// This is the color the lines will be drawn in
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
/// <reference path="../../build/phaser-fx.d.ts" />
|
||||
/// <reference path="../../Plugins/CameraFX/Scanlines.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
@@ -13,14 +13,14 @@
|
||||
|
||||
}
|
||||
|
||||
var scanlines: Phaser.FX.Camera.Scanlines;
|
||||
var scanlines: Phaser.Plugins.CameraFX.Scanlines;
|
||||
|
||||
function create() {
|
||||
|
||||
game.world.setSize(1216, 896);
|
||||
|
||||
// Add our effect to the camera
|
||||
scanlines = <Phaser.FX.Camera.Scanlines> game.camera.fx.add(Phaser.FX.Camera.Scanlines);
|
||||
scanlines = <Phaser.Plugins.CameraFX.Scanlines> game.camera.plugins.add(Phaser.Plugins.CameraFX.Scanlines);
|
||||
|
||||
// We'll have the scanlines spaced out every 2 pixels
|
||||
scanlines.spacing = 2;
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render);
|
||||
|
||||
var btn1: Phaser.Button,
|
||||
btn2: Phaser.Button,
|
||||
btn3: Phaser.Button;
|
||||
var btn1: Phaser.UI.Button,
|
||||
btn2: Phaser.UI.Button,
|
||||
btn3: Phaser.UI.Button;
|
||||
var fx;
|
||||
|
||||
function init() {
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render);
|
||||
|
||||
var btn1: Phaser.Button,
|
||||
btn2: Phaser.Button,
|
||||
btn3: Phaser.Button;
|
||||
var btn1: Phaser.UI.Button,
|
||||
btn2: Phaser.UI.Button,
|
||||
btn3: Phaser.UI.Button;
|
||||
var fx;
|
||||
|
||||
function init() {
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render);
|
||||
|
||||
var btn1: Phaser.Button,
|
||||
btn2: Phaser.Button,
|
||||
btn3: Phaser.Button;
|
||||
var btn1: Phaser.UI.Button,
|
||||
btn2: Phaser.UI.Button,
|
||||
btn3: Phaser.UI.Button;
|
||||
var fx;
|
||||
|
||||
function init() {
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
var ufo: Phaser.Sprite,
|
||||
speed: Number = 4;
|
||||
|
||||
var btn0: Phaser.Button,
|
||||
btn1: Phaser.Button,
|
||||
btn2: Phaser.Button,
|
||||
btn3: Phaser.Button;
|
||||
var btn0: Phaser.UI.Button,
|
||||
btn1: Phaser.UI.Button,
|
||||
btn2: Phaser.UI.Button,
|
||||
btn3: Phaser.UI.Button;
|
||||
var style: String = 'default';
|
||||
|
||||
function init() {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
var game = new Phaser.Game(this, 'game', 320, 400, init, create);
|
||||
|
||||
var emitter: Phaser.Emitter;
|
||||
var emitter: Phaser.ArcadeEmitter;
|
||||
|
||||
function init() {
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, init, create);
|
||||
|
||||
var emitter: Phaser.Emitter;
|
||||
var emitter: Phaser.ArcadeEmitter;
|
||||
|
||||
function init() {
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
|
||||
var emitter: Phaser.Emitter;
|
||||
var emitter: Phaser.ArcadeEmitter;
|
||||
|
||||
function init() {
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
}
|
||||
|
||||
var scroller: Phaser.ScrollZone;
|
||||
var emitter: Phaser.Emitter;
|
||||
var emitter: Phaser.ArcadeEmitter;
|
||||
|
||||
function create() {
|
||||
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
|
||||
var emitter1: Phaser.Emitter;
|
||||
var emitter2: Phaser.Emitter;
|
||||
var emitter3: Phaser.Emitter;
|
||||
var emitter4: Phaser.Emitter;
|
||||
var emitter5: Phaser.Emitter;
|
||||
var emitter6: Phaser.Emitter;
|
||||
var emitter1: Phaser.ArcadeEmitter;
|
||||
var emitter2: Phaser.ArcadeEmitter;
|
||||
var emitter3: Phaser.ArcadeEmitter;
|
||||
var emitter4: Phaser.ArcadeEmitter;
|
||||
var emitter5: Phaser.ArcadeEmitter;
|
||||
var emitter6: Phaser.ArcadeEmitter;
|
||||
|
||||
function init() {
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@ var __extends = this.__extends || function (d, b) {
|
||||
d.prototype = new __();
|
||||
};
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
/// <reference path="../../Phaser/gameobjects/Particle.ts" />
|
||||
/// <reference path="../../Phaser/gameobjects/Emitter.ts" />
|
||||
/// <reference path="../../Phaser/particles/ArcadeParticle.ts" />
|
||||
/// <reference path="../../Phaser/particles/ArcadeEmitter.ts" />
|
||||
// Actually we could achieve the same result as this by using a sprite sheet and basic Particle
|
||||
// but it still shows you how to use it properly from TypeScript, so it was worth making
|
||||
var customParticle = (function (_super) {
|
||||
@@ -22,7 +22,7 @@ var customParticle = (function (_super) {
|
||||
this.texture.loadImage(game.math.getRandom(s));
|
||||
}
|
||||
return customParticle;
|
||||
})(Phaser.Particle);
|
||||
})(Phaser.ArcadeParticle);
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, init, create);
|
||||
var emitter;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
/// <reference path="../../Phaser/gameobjects/Particle.ts" />
|
||||
/// <reference path="../../Phaser/gameobjects/Emitter.ts" />
|
||||
/// <reference path="../../Phaser/particles/ArcadeParticle.ts" />
|
||||
/// <reference path="../../Phaser/particles/ArcadeEmitter.ts" />
|
||||
|
||||
// Actually we could achieve the same result as this by using a sprite sheet and basic Particle
|
||||
// but it still shows you how to use it properly from TypeScript, so it was worth making
|
||||
class customParticle extends Phaser.Particle {
|
||||
class customParticle extends Phaser.ArcadeParticle {
|
||||
|
||||
constructor(game:Phaser.Game) {
|
||||
|
||||
@@ -21,7 +21,7 @@ class customParticle extends Phaser.Particle {
|
||||
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, init, create);
|
||||
|
||||
var emitter: Phaser.Emitter;
|
||||
var emitter: Phaser.ArcadeEmitter;
|
||||
|
||||
function init() {
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
|
||||
var leftEmitter: Phaser.Emitter;
|
||||
var rightEmitter: Phaser.Emitter;
|
||||
var leftEmitter: Phaser.ArcadeEmitter;
|
||||
var rightEmitter: Phaser.ArcadeEmitter;
|
||||
|
||||
function init() {
|
||||
|
||||
|
||||
+2380
-2623
File diff suppressed because it is too large
Load Diff
@@ -17,7 +17,7 @@
|
||||
}
|
||||
|
||||
var scroller: Phaser.ScrollZone;
|
||||
var emitter: Phaser.Emitter;
|
||||
var emitter: Phaser.ArcadeEmitter;
|
||||
var ship: Phaser.Sprite;
|
||||
var bullets: Phaser.Group;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/// <reference path="../../Phaser/gameobjects/Tilemap.ts" />
|
||||
/// <reference path="../../Phaser/tilemap/Tilemap.ts" />
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/// <reference path="../../Phaser/gameobjects/Tilemap.ts" />
|
||||
/// <reference path="../../Phaser/tilemap/Tilemap.ts" />
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/// <reference path="../../Phaser/gameobjects/Tilemap.ts" />
|
||||
/// <reference path="../../Phaser/tilemap/Tilemap.ts" />
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/// <reference path="../../Phaser/gameobjects/Tilemap.ts" />
|
||||
/// <reference path="../../Phaser/tilemap/Tilemap.ts" />
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
@@ -16,7 +16,7 @@
|
||||
}
|
||||
|
||||
var map: Phaser.Tilemap;
|
||||
var emitter: Phaser.Emitter;
|
||||
var emitter: Phaser.ArcadeEmitter;
|
||||
var marker: Phaser.Sprite;
|
||||
|
||||
function create() {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/// <reference path="../../Phaser/gameobjects/Tilemap.ts" />
|
||||
/// <reference path="../../Phaser/tilemap/Tilemap.ts" />
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/// <reference path="../../Phaser/gameobjects/Tilemap.ts" />
|
||||
/// <reference path="../../Phaser/tilemap/Tilemap.ts" />
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/// <reference path="../../Phaser/gameobjects/Tilemap.ts" />
|
||||
/// <reference path="../../Phaser/tilemap/Tilemap.ts" />
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/// <reference path="../../Phaser/gameobjects/Tilemap.ts" />
|
||||
/// <reference path="../../Phaser/tilemap/Tilemap.ts" />
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
Vendored
+1000
-1134
File diff suppressed because it is too large
Load Diff
+2365
-2613
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"Contact.js","sources":["Contact.ts"],"names":["Phaser","Phaser.Physics","Phaser.Physics.Contact","Phaser.Physics.Contact.constructor"],"mappings":"AAYA,IAAO,MAAM;AAiDZ,CAjDD,UAAO,MAAM;IAZbA,wCAAwCA;IACxCA,6CAA6CA;IAC7CA,mCAAmCA;IACnCA,gCAAgCA;IAChCA,wCAAwCA;IAExCA;;;;MAIEA;KAEKA,UAAOA,OAAOA;QAEjBC;YAEIC,SAFSA,OAAOA,CAEJA,CAACA,EAAEA,CAACA,EAAEA,CAACA,EAAEA,IAAIA;gBAErBC,IAAIA,CAACA,IAAIA,GAAGA,IAAIA;gBAChBA,IAAIA,CAACA,KAAKA,GAAGA,CAACA;gBACdA,IAAIA,CAACA,MAAMA,GAAGA,CAACA;gBACfA,IAAIA,CAACA,KAAKA,GAAGA,CAACA;gBACdA,IAAIA,CAACA,YAAYA,GAAGA,CAACA;gBACrBA,IAAIA,CAACA,gBAAgBA,GAAGA,CAACA;gBAEzBA,IAAIA,CAACA,EAAEA,GAAGA,IAAIA,MAAMA,CAACA,IAAIA,EAAAA;gBACzBA,IAAIA,CAACA,EAAEA,GAAGA,IAAIA,MAAMA,CAACA,IAAIA,EAAAA;gBACzBA,IAAIA,CAACA,QAAQA,GAAGA,IAAIA,MAAMA,CAACA,IAAIA,EAAAA;gBAC/BA,IAAIA,CAACA,QAAQA,GAAGA,IAAIA,MAAMA,CAACA,IAAIA,EAAAA;YAEnCA,CAACA;YA6BLD;AAACA,QAADA,CAACA,IAAAD;QA7CDA,0BA6CCA,QAAAA;IAELA,CAACA,2CAAAD;IAjDMA;AAiDNA,CAAAA,2BAAA"}
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"Plane.js","sources":["Plane.ts"],"names":["Phaser","Phaser.Physics","Phaser.Physics.Plane","Phaser.Physics.Plane.constructor"],"mappings":"AAWA,IAAO,MAAM;AAgBZ,CAhBD,UAAO,MAAM;IAXbA,wCAAwCA;IACxCA,6CAA6CA;IAC7CA,mCAAmCA;IACnCA,gCAAgCA;IAEhCA;;;;MAIEA;KAEKA,UAAOA,OAAOA;QAEjBC;YAEIC,SAFSA,KAAKA,CAEFA,MAAmBA,EAAEA,CAASA;gBAEtCC,IAAIA,CAACA,MAAMA,GAAGA,MAAMA;gBACpBA,IAAIA,CAACA,CAACA,GAAGA,CAACA;YAEdA,CAACA;YAKLD;AAACA,QAADA,CAACA,IAAAD;QAZDA,sBAYCA,QAAAA;IAELA,CAACA,2CAAAD;IAhBMA;AAgBNA,CAAAA,2BAAA"}
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,53 @@
|
||||
/// <reference path="../Game.ts" />
|
||||
/// <reference path="Vec2Utils.ts" />
|
||||
/**
|
||||
* Phaser - 2D Transform
|
||||
*
|
||||
* A 2D Transform
|
||||
*/
|
||||
var Phaser;
|
||||
(function (Phaser) {
|
||||
var Transform = (function () {
|
||||
/**
|
||||
* Creates a new 2D Transform object.
|
||||
* @class Transform
|
||||
* @constructor
|
||||
* @return {Transform} This object
|
||||
**/
|
||||
function Transform(pos, angle) {
|
||||
this.t = Phaser.Vec2Utils.clone(pos);
|
||||
this.c = Math.cos(angle);
|
||||
this.s = Math.sin(angle);
|
||||
this.angle = angle;
|
||||
}
|
||||
Transform.prototype.toString = function () {
|
||||
return 't=' + this.t.toString() + ' c=' + this.c + ' s=' + this.s + ' a=' + this.angle;
|
||||
};
|
||||
Transform.prototype.setTo = function (pos, angle) {
|
||||
this.t.copyFrom(pos);
|
||||
this.c = Math.cos(angle);
|
||||
this.s = Math.sin(angle);
|
||||
return this;
|
||||
};
|
||||
Transform.prototype.setRotation = function (angle) {
|
||||
if(angle !== this.angle) {
|
||||
this.c = Math.cos(angle);
|
||||
this.s = Math.sin(angle);
|
||||
this.angle = angle;
|
||||
}
|
||||
return this;
|
||||
};
|
||||
Transform.prototype.setPosition = function (p) {
|
||||
this.t.copyFrom(p);
|
||||
return this;
|
||||
};
|
||||
Transform.prototype.identity = function () {
|
||||
this.t.setTo(0, 0);
|
||||
this.c = 1;
|
||||
this.s = 0;
|
||||
return this;
|
||||
};
|
||||
return Transform;
|
||||
})();
|
||||
Phaser.Transform = Transform;
|
||||
})(Phaser || (Phaser = {}));
|
||||
@@ -0,0 +1,39 @@
|
||||
/// <reference path="../Game.ts" />
|
||||
/// <reference path="Vec2.ts" />
|
||||
/// <reference path="Transform.ts" />
|
||||
/**
|
||||
* Phaser - TransformUtils
|
||||
*
|
||||
* A collection of methods useful for manipulating and performing operations on 2D Transforms.
|
||||
*
|
||||
*/
|
||||
var Phaser;
|
||||
(function (Phaser) {
|
||||
var TransformUtils = (function () {
|
||||
function TransformUtils() { }
|
||||
TransformUtils.rotate = function rotate(t, v, out) {
|
||||
if (typeof out === "undefined") { out = new Phaser.Vec2(); }
|
||||
//return new vec2(v.x * this.c - v.y * this.s, v.x * this.s + v.y * this.c);
|
||||
return out.setTo(v.x * t.c - v.y * t.s, v.x * t.s + v.y * t.c);
|
||||
};
|
||||
TransformUtils.unrotate = function unrotate(t, v, out) {
|
||||
if (typeof out === "undefined") { out = new Phaser.Vec2(); }
|
||||
//return new vec2(v.x * this.c + v.y * this.s, -v.x * this.s + v.y * this.c);
|
||||
return out.setTo(v.x * t.c + v.y * t.s, -v.x * t.s + v.y * t.c);
|
||||
};
|
||||
TransformUtils.transform = function transform(t, v, out) {
|
||||
if (typeof out === "undefined") { out = new Phaser.Vec2(); }
|
||||
//return new vec2(v.x * this.c - v.y * this.s + this.t.x, v.x * this.s + v.y * this.c + this.t.y);
|
||||
return out.setTo(v.x * t.c - v.y * t.s + t.t.x, v.x * t.s + v.y * t.c + t.t.y);
|
||||
};
|
||||
TransformUtils.untransform = function untransform(t, v, out) {
|
||||
if (typeof out === "undefined") { out = new Phaser.Vec2(); }
|
||||
var px = v.x - t.t.x;
|
||||
var py = v.y - t.t.y;
|
||||
//return new vec2(px * this.c + py * this.s, -px * this.s + py * this.c);
|
||||
return out.setTo(px * t.c + py * t.s, -px * t.s + py * t.c);
|
||||
};
|
||||
return TransformUtils;
|
||||
})();
|
||||
Phaser.TransformUtils = TransformUtils;
|
||||
})(Phaser || (Phaser = {}));
|
||||
Reference in New Issue
Block a user