Whole codebase updated to TypeScript 0.9.1, phew!

This commit is contained in:
Richard Davey 2013-08-08 19:16:47 +01:00
parent df32190db8
commit 1248a6c06e
129 changed files with 38471 additions and 30343 deletions

Binary file not shown.

BIN
Docs/phaser checkboxes.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
Docs/phaser power tools.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

38
Phaser/.gitignore vendored
View file

@ -1,38 +0,0 @@
#ignore thumbnails created by windows
Thumbs.db
#Ignore files build by Visual Studio
*.obj
*.exe
*.pdb
*.user
*.aps
*.pch
*.vspscc
*_i.c
*_p.c
*.ncb
*.suo
*.sln
*.tlb
*.tlh
*.bak
*.cache
*.ilk
*.log
*.map
*.orig
*.js
!phaser.js
*.map
*.config
.DS_Store
[Bb]in
[Dd]ebug*/
*.lib
*.sbr
obj/
[Rr]elease*/
_ReSharper*/
[Tt]est[Rr]esult*

View file

@ -1,33 +1,4 @@
/// <reference path="geom/Rectangle.ts" />
/// <reference path="math/LinkedList.ts" />
/// <reference path="math/QuadTree.ts" />
/// <reference path="geom/Point.ts" />
/// <reference path="math/Vec2.ts" />
/// <reference path="geom/Circle.ts" />
/// <reference path="core/Group.ts" />
/// <reference path="core/Signal.ts" />
/// <reference path="core/SignalBinding.ts" />
/// <reference path="loader/Loader.ts" />
/// <reference path="net/Net.ts" />
/// <reference path="loader/Cache.ts" />
/// <reference path="math/GameMath.ts" />
/// <reference path="math/RandomDataGenerator.ts" />
/// <reference path="cameras/CameraManager.ts" />
/// <reference path="gameobjects/GameObjectFactory.ts" />
/// <reference path="sound/SoundManager.ts" />
/// <reference path="sound/Sound.ts" />
/// <reference path="Stage.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/InputManager.ts" />
/// <reference path="renderers/IRenderer.ts" />
/// <reference path="renderers/HeadlessRenderer.ts" />
/// <reference path="renderers/canvas/CanvasRenderer.ts" />
/// <reference path="utils/DebugUtils.ts" />
/// <reference path="core/PluginManager.ts" />
/// <reference path="_definitions.ts" />
/**
* Phaser - Game
@ -242,7 +213,7 @@ module Phaser {
* @type {Time}
*/
public time: Phaser.TimeManager;
/**
* Reference to the tween manager.
* @type {TweenManager}
@ -259,7 +230,7 @@ module Phaser {
* Reference to the physics manager.
* @type {Physics.Manager}
*/
public physics: Phaser.Physics.Manager;
//public physics: Phaser.Physics.Manager;
/**
* Instance of repeatable random data generator helper.
@ -272,7 +243,7 @@ module Phaser {
* @type {Device}
*/
public device: Phaser.Device;
/**
* Reference to the render manager
* @type {RenderManager}
@ -329,7 +300,7 @@ module Phaser {
this.input = new Phaser.InputManager(this);
this.sound = new Phaser.SoundManager(this);
this.rnd = new Phaser.RandomDataGenerator([(Date.now() * Math.random()).toString()]);
this.physics = new Phaser.Physics.Manager(this);
//this.physics = new Phaser.Physics.Manager(this);
this.plugins = new Phaser.PluginManager(this, this);
this.load.onLoadComplete.addOnce(this.loadComplete, this);
@ -461,7 +432,6 @@ module Phaser {
}
this.plugins.postRender();
}
/**
@ -707,7 +677,7 @@ module Phaser {
}
public get camera(): Camera {
public get camera(): Phaser.Camera {
return this.world.cameras.current;
}

View file

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<ProjectGuid>{A90BE60F-CAEA-4747-904A-CDB097BA2459}</ProjectGuid>
<ProjectGuid>{BB30C59B-5B34-4F7C-B5CC-8D49EA280EDA}</ProjectGuid>
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<OutputPath>bin</OutputPath>
@ -15,6 +15,392 @@
<IISExpressWindowsAuthentication />
<IISExpressUseClassicPipelineMode />
</PropertyGroup>
<ItemGroup>
<None Include="math\Mat3.ts" />
<None Include="math\GameMath.ts" />
<None Include="Game.ts" />
<None Include="core\Signal.ts" />
<None Include="core\Plugin.ts" />
<None Include="core\Group.ts" />
<None Include="cameras\CameraManager.ts" />
<None Include="cameras\Camera.ts" />
<None Include="animation\Animation.ts" />
<Content Include="animation\Animation.js">
<DependentUpon>Animation.ts</DependentUpon>
</Content>
<None Include="animation\AnimationManager.ts" />
<Content Include="animation\AnimationManager.js">
<DependentUpon>AnimationManager.ts</DependentUpon>
</Content>
<None Include="animation\Frame.ts" />
<Content Include="animation\Frame.js">
<DependentUpon>Frame.ts</DependentUpon>
</Content>
<None Include="animation\FrameData.ts" />
<Content Include="animation\FrameData.js">
<DependentUpon>FrameData.ts</DependentUpon>
</Content>
<Content Include="cameras\Camera.js">
<DependentUpon>Camera.ts</DependentUpon>
</Content>
<Content Include="cameras\CameraManager.js">
<DependentUpon>CameraManager.ts</DependentUpon>
</Content>
<Content Include="core\Group.js">
<DependentUpon>Group.ts</DependentUpon>
</Content>
<Content Include="core\Plugin.js">
<DependentUpon>Plugin.ts</DependentUpon>
</Content>
<None Include="core\PluginManager.ts" />
<Content Include="core\PluginManager.js">
<DependentUpon>PluginManager.ts</DependentUpon>
</Content>
<Content Include="core\Signal.js">
<DependentUpon>Signal.ts</DependentUpon>
</Content>
<None Include="core\SignalBinding.ts" />
<Content Include="core\SignalBinding.js">
<DependentUpon>SignalBinding.ts</DependentUpon>
</Content>
<None Include="display\CSS3Filters.ts" />
<Content Include="display\CSS3Filters.js">
<DependentUpon>CSS3Filters.ts</DependentUpon>
</Content>
<None Include="display\DynamicTexture.ts" />
<Content Include="display\DynamicTexture.js">
<DependentUpon>DynamicTexture.ts</DependentUpon>
</Content>
<None Include="display\Texture.ts" />
<Content Include="display\Texture.js">
<DependentUpon>Texture.ts</DependentUpon>
</Content>
<Content Include="Game.js">
<DependentUpon>Game.ts</DependentUpon>
</Content>
<None Include="geom\Rectangle.ts" />
<None Include="geom\Point.ts" />
<None Include="geom\Circle.ts" />
<None Include="gameobjects\Events.ts" />
<Content Include="gameobjects\Events.js">
<DependentUpon>Events.ts</DependentUpon>
</Content>
<None Include="gameobjects\IGameObject.ts" />
<None Include="gameobjects\GameObjectFactory.ts" />
<Content Include="gameobjects\GameObjectFactory.js">
<DependentUpon>GameObjectFactory.ts</DependentUpon>
</Content>
<Content Include="gameobjects\IGameObject.js">
<DependentUpon>IGameObject.ts</DependentUpon>
</Content>
<None Include="gameobjects\TransformManager.ts" />
<None Include="gameobjects\Sprite.ts" />
<None Include="gameobjects\ScrollZone.ts" />
<None Include="gameobjects\ScrollRegion.ts" />
<Content Include="gameobjects\ScrollRegion.js">
<DependentUpon>ScrollRegion.ts</DependentUpon>
</Content>
<Content Include="gameobjects\ScrollZone.js">
<DependentUpon>ScrollZone.ts</DependentUpon>
</Content>
<Content Include="gameobjects\Sprite.js">
<DependentUpon>Sprite.ts</DependentUpon>
</Content>
<Content Include="gameobjects\TransformManager.js">
<DependentUpon>TransformManager.ts</DependentUpon>
</Content>
<Content Include="geom\Circle.js">
<DependentUpon>Circle.ts</DependentUpon>
</Content>
<None Include="geom\Line.ts" />
<Content Include="geom\Line.js">
<DependentUpon>Line.ts</DependentUpon>
</Content>
<Content Include="geom\Point.js">
<DependentUpon>Point.ts</DependentUpon>
</Content>
<Content Include="geom\Rectangle.js">
<DependentUpon>Rectangle.ts</DependentUpon>
</Content>
<None Include="loader\Cache.ts" />
<None Include="loader\AnimationLoader.ts" />
<None Include="input\InputHandler.ts" />
<Content Include="input\InputHandler.js">
<DependentUpon>InputHandler.ts</DependentUpon>
</Content>
<None Include="input\InputManager.ts" />
<Content Include="input\InputManager.js">
<DependentUpon>InputManager.ts</DependentUpon>
</Content>
<None Include="input\Keyboard.ts" />
<Content Include="input\Keyboard.js">
<DependentUpon>Keyboard.ts</DependentUpon>
</Content>
<None Include="input\Mouse.ts" />
<Content Include="input\Mouse.js">
<DependentUpon>Mouse.ts</DependentUpon>
</Content>
<None Include="input\MSPointer.ts" />
<Content Include="input\MSPointer.js">
<DependentUpon>MSPointer.ts</DependentUpon>
</Content>
<None Include="input\Pointer.ts" />
<Content Include="input\Pointer.js">
<DependentUpon>Pointer.ts</DependentUpon>
</Content>
<None Include="input\Touch.ts" />
<Content Include="input\Touch.js">
<DependentUpon>Touch.ts</DependentUpon>
</Content>
<Content Include="loader\AnimationLoader.js">
<DependentUpon>AnimationLoader.ts</DependentUpon>
</Content>
<Content Include="loader\Cache.js">
<DependentUpon>Cache.ts</DependentUpon>
</Content>
<None Include="loader\Loader.ts" />
<Content Include="loader\Loader.js">
<DependentUpon>Loader.ts</DependentUpon>
</Content>
<Content Include="math\GameMath.js">
<DependentUpon>GameMath.ts</DependentUpon>
</Content>
<None Include="math\LinkedList.ts" />
<Content Include="math\LinkedList.js">
<DependentUpon>LinkedList.ts</DependentUpon>
</Content>
<Content Include="math\Mat3.js">
<DependentUpon>Mat3.ts</DependentUpon>
</Content>
<None Include="math\Mat3Utils.ts" />
<Content Include="math\Mat3Utils.js">
<DependentUpon>Mat3Utils.ts</DependentUpon>
</Content>
<None Include="math\QuadTree.ts" />
<Content Include="math\QuadTree.js">
<DependentUpon>QuadTree.ts</DependentUpon>
</Content>
<None Include="net\Net.ts" />
<TypeScriptCompile Include="math\RandomDataGenerator.ts" />
<Content Include="math\RandomDataGenerator.js">
<DependentUpon>RandomDataGenerator.ts</DependentUpon>
</Content>
<Content Include="net\Net.js">
<DependentUpon>Net.ts</DependentUpon>
</Content>
<None Include="time\TimeManager.ts" />
<None Include="system\Device.ts" />
<None Include="sound\SoundManager.ts" />
<None Include="sound\Sound.ts" />
<None Include="renderers\IRenderer.ts" />
<None Include="renderers\HeadlessRenderer.ts" />
<None Include="physics\arcade\Body.ts" />
<Content Include="physics\arcade\Body.js">
<DependentUpon>Body.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="renderers\canvas\CameraRenderer.ts" />
<Content Include="renderers\canvas\CameraRenderer.js">
<DependentUpon>CameraRenderer.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="renderers\canvas\GeometryRenderer.ts" />
<TypeScriptCompile Include="renderers\canvas\CanvasRenderer.ts" />
<Content Include="renderers\canvas\CanvasRenderer.js">
<DependentUpon>CanvasRenderer.ts</DependentUpon>
</Content>
<Content Include="renderers\canvas\GeometryRenderer.js">
<DependentUpon>GeometryRenderer.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="renderers\canvas\GroupRenderer.ts" />
<Content Include="renderers\canvas\GroupRenderer.js">
<DependentUpon>GroupRenderer.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="renderers\canvas\ScrollZoneRenderer.ts" />
<Content Include="renderers\canvas\ScrollZoneRenderer.js">
<DependentUpon>ScrollZoneRenderer.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="renderers\canvas\SpriteRenderer.ts" />
<Content Include="renderers\canvas\SpriteRenderer.js">
<DependentUpon>SpriteRenderer.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="renderers\canvas\TilemapRenderer.ts" />
<Content Include="renderers\canvas\TilemapRenderer.js">
<DependentUpon>TilemapRenderer.ts</DependentUpon>
</Content>
<Content Include="renderers\HeadlessRenderer.js">
<DependentUpon>HeadlessRenderer.ts</DependentUpon>
</Content>
<Content Include="renderers\IRenderer.js">
<DependentUpon>IRenderer.ts</DependentUpon>
</Content>
<Content Include="sound\Sound.js">
<DependentUpon>Sound.ts</DependentUpon>
</Content>
<Content Include="sound\SoundManager.js">
<DependentUpon>SoundManager.ts</DependentUpon>
</Content>
<None Include="Stage.ts" />
<Content Include="Stage.js">
<DependentUpon>Stage.ts</DependentUpon>
</Content>
<None Include="State.ts" />
<Content Include="State.js">
<DependentUpon>State.ts</DependentUpon>
</Content>
<Content Include="system\Device.js">
<DependentUpon>Device.ts</DependentUpon>
</Content>
<None Include="system\RequestAnimationFrame.ts" />
<Content Include="system\RequestAnimationFrame.js">
<DependentUpon>RequestAnimationFrame.ts</DependentUpon>
</Content>
<None Include="system\StageScaleMode.ts" />
<None Include="system\screens\BootScreen.ts" />
<Content Include="system\screens\BootScreen.js">
<DependentUpon>BootScreen.ts</DependentUpon>
</Content>
<None Include="system\screens\OrientationScreen.ts" />
<Content Include="system\screens\OrientationScreen.js">
<DependentUpon>OrientationScreen.ts</DependentUpon>
</Content>
<None Include="system\screens\PauseScreen.ts" />
<Content Include="system\screens\PauseScreen.js">
<DependentUpon>PauseScreen.ts</DependentUpon>
</Content>
<Content Include="system\StageScaleMode.js">
<DependentUpon>StageScaleMode.ts</DependentUpon>
</Content>
<None Include="tilemap\Tile.ts" />
<Content Include="tilemap\Tile.js">
<DependentUpon>Tile.ts</DependentUpon>
</Content>
<None Include="tilemap\Tilemap.ts" />
<Content Include="tilemap\Tilemap.js">
<DependentUpon>Tilemap.ts</DependentUpon>
</Content>
<None Include="tilemap\TilemapLayer.ts" />
<Content Include="tilemap\TilemapLayer.js">
<DependentUpon>TilemapLayer.ts</DependentUpon>
</Content>
<Content Include="time\TimeManager.js">
<DependentUpon>TimeManager.ts</DependentUpon>
</Content>
<None Include="tweens\TweenManager.ts" />
<None Include="tweens\Tween.ts" />
<None Include="tweens\easing\Back.ts" />
<Content Include="tweens\easing\Back.js">
<DependentUpon>Back.ts</DependentUpon>
</Content>
<None Include="tweens\easing\Bounce.ts" />
<Content Include="tweens\easing\Bounce.js">
<DependentUpon>Bounce.ts</DependentUpon>
</Content>
<None Include="tweens\easing\Circular.ts" />
<Content Include="tweens\easing\Circular.js">
<DependentUpon>Circular.ts</DependentUpon>
</Content>
<None Include="tweens\easing\Cubic.ts" />
<Content Include="tweens\easing\Cubic.js">
<DependentUpon>Cubic.ts</DependentUpon>
</Content>
<None Include="tweens\easing\Elastic.ts" />
<Content Include="tweens\easing\Elastic.js">
<DependentUpon>Elastic.ts</DependentUpon>
</Content>
<None Include="tweens\easing\Exponential.ts" />
<Content Include="tweens\easing\Exponential.js">
<DependentUpon>Exponential.ts</DependentUpon>
</Content>
<None Include="tweens\easing\Linear.ts" />
<Content Include="tweens\easing\Linear.js">
<DependentUpon>Linear.ts</DependentUpon>
</Content>
<None Include="tweens\easing\Quadratic.ts" />
<Content Include="tweens\easing\Quadratic.js">
<DependentUpon>Quadratic.ts</DependentUpon>
</Content>
<None Include="tweens\easing\Quartic.ts" />
<Content Include="tweens\easing\Quartic.js">
<DependentUpon>Quartic.ts</DependentUpon>
</Content>
<None Include="tweens\easing\Quintic.ts" />
<Content Include="tweens\easing\Quintic.js">
<DependentUpon>Quintic.ts</DependentUpon>
</Content>
<None Include="tweens\easing\Sinusoidal.ts" />
<Content Include="tweens\easing\Sinusoidal.js">
<DependentUpon>Sinusoidal.ts</DependentUpon>
</Content>
<Content Include="tweens\Tween.js">
<DependentUpon>Tween.ts</DependentUpon>
</Content>
<Content Include="tweens\TweenManager.js">
<DependentUpon>TweenManager.ts</DependentUpon>
</Content>
<None Include="utils\CircleUtils.ts" />
<None Include="ui\Button.ts" />
<Content Include="ui\Button.js">
<DependentUpon>Button.ts</DependentUpon>
</Content>
<Content Include="utils\CircleUtils.js">
<DependentUpon>CircleUtils.ts</DependentUpon>
</Content>
<None Include="utils\ColorUtils.ts" />
<Content Include="utils\ColorUtils.js">
<DependentUpon>ColorUtils.ts</DependentUpon>
</Content>
<None Include="utils\PointUtils.ts" />
<None Include="utils\DebugUtils.ts" />
<Content Include="utils\DebugUtils.js">
<DependentUpon>DebugUtils.ts</DependentUpon>
</Content>
<Content Include="utils\PointUtils.js">
<DependentUpon>PointUtils.ts</DependentUpon>
</Content>
<None Include="utils\RectangleUtils.ts" />
<Content Include="utils\RectangleUtils.js">
<DependentUpon>RectangleUtils.ts</DependentUpon>
</Content>
<None Include="utils\SpriteUtils.ts" />
<Content Include="utils\SpriteUtils.js">
<DependentUpon>SpriteUtils.ts</DependentUpon>
</Content>
<None Include="World.ts" />
<Content Include="World.js">
<DependentUpon>World.ts</DependentUpon>
</Content>
<Content Include="_definitions.js">
<DependentUpon>_definitions.ts</DependentUpon>
</Content>
<None Include="_definitions.ts" />
<None Include="Phaser.ts" />
<TypeScriptCompile Include="math\Vec2.ts" />
<Content Include="math\Vec2.js">
<DependentUpon>Vec2.ts</DependentUpon>
</Content>
<None Include="math\Vec2Utils.ts" />
<Content Include="math\Vec2Utils.js">
<DependentUpon>Vec2Utils.ts</DependentUpon>
</Content>
<Content Include="Phaser.js">
<DependentUpon>Phaser.ts</DependentUpon>
</Content>
<None Include="Statics.ts" />
<Content Include="Statics.js">
<DependentUpon>Statics.ts</DependentUpon>
</Content>
<Content Include="web.config" />
</ItemGroup>
<ItemGroup>
<None Include="web.Debug.config">
<DependentUpon>web.config</DependentUpon>
</None>
<None Include="web.Release.config">
<DependentUpon>web.config</DependentUpon>
</None>
</ItemGroup>
<ItemGroup>
<Folder Include="particles\" />
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
@ -44,418 +430,19 @@
</ProjectExtensions>
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
<TypeScriptTarget>ES5</TypeScriptTarget>
<TypeScriptIncludeComments>true</TypeScriptIncludeComments>
<TypeScriptRemoveComments>false</TypeScriptRemoveComments>
<TypeScriptSourceMap>false</TypeScriptSourceMap>
<TypeScriptOutFile>../build/phaser.js</TypeScriptOutFile>
<TypeScriptGeneratesDeclarations>false</TypeScriptGeneratesDeclarations>
<TypeScriptOutFile>../build/phaser-debug.js</TypeScriptOutFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<TypeScriptTarget>ES5</TypeScriptTarget>
<TypeScriptIncludeComments>false</TypeScriptIncludeComments>
<TypeScriptRemoveComments>true</TypeScriptRemoveComments>
<TypeScriptSourceMap>false</TypeScriptSourceMap>
<TypeScriptOutFile>../build/phaser.js</TypeScriptOutFile>
<TypeScriptGeneratesDeclarations>false</TypeScriptGeneratesDeclarations>
<TypeScriptOutFile>../build/phaser-release.js</TypeScriptOutFile>
</PropertyGroup>
<ItemGroup />
<ItemGroup>
<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="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\Texture.ts" />
<TypeScriptCompile Include="display\DynamicTexture.ts" />
<TypeScriptCompile Include="display\CSS3Filters.ts" />
<Content Include="display\CSS3Filters.js">
<DependentUpon>CSS3Filters.ts</DependentUpon>
</Content>
<Content Include="display\DynamicTexture.js">
<DependentUpon>DynamicTexture.ts</DependentUpon>
</Content>
<Content Include="display\Texture.js">
<DependentUpon>Texture.ts</DependentUpon>
</Content>
<Content Include="Game.js">
<DependentUpon>Game.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="gameobjects\Sprite.ts" />
<TypeScriptCompile Include="gameobjects\IGameObject.ts" />
<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" />
<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>
<TypeScriptCompile Include="geom\Line.ts" />
<Content Include="geom\Line.js">
<DependentUpon>Line.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="geom\Point.ts" />
<Content Include="geom\Point.js">
<DependentUpon>Point.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="geom\Rectangle.ts" />
<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>
<TypeScriptCompile Include="gameobjects\GameObjectFactory.ts" />
<Content Include="gameobjects\GameObjectFactory.js">
<DependentUpon>GameObjectFactory.ts</DependentUpon>
</Content>
<Content Include="gameobjects\Sprite.js">
<DependentUpon>Sprite.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="utils\PointUtils.ts" />
<TypeScriptCompile Include="utils\CircleUtils.ts" />
<TypeScriptCompile Include="Statics.ts" />
<TypeScriptCompile Include="renderers\HeadlessRenderer.ts" />
<TypeScriptCompile Include="math\QuadTree.ts" />
<TypeScriptCompile Include="math\Mat3.ts" />
<Content Include="math\Mat3.js">
<DependentUpon>Mat3.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="math\Mat3Utils.ts" />
<Content Include="math\Mat3Utils.js">
<DependentUpon>Mat3Utils.ts</DependentUpon>
</Content>
<Content Include="math\QuadTree.js">
<DependentUpon>QuadTree.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="math\LinkedList.ts" />
<Content Include="math\LinkedList.js">
<DependentUpon>LinkedList.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="math\Vec2.ts" />
<Content Include="math\Vec2.js">
<DependentUpon>Vec2.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="net\Net.ts" />
<Content Include="net\Net.js">
<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>
</Content>
<TypeScriptCompile Include="physics\Manager.ts" />
<TypeScriptCompile Include="physics\arcade\Body.ts" />
<Content Include="physics\arcade\Body.js">
<DependentUpon>Body.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="physics\arcade\Motion.ts" />
<Content Include="physics\arcade\Motion.js">
<DependentUpon>Motion.ts</DependentUpon>
</Content>
<Content Include="physics\Manager.js">
<DependentUpon>Manager.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="renderers\canvas\SpriteRenderer.ts" />
<TypeScriptCompile Include="renderers\canvas\CanvasRenderer.ts" />
<TypeScriptCompile Include="renderers\canvas\CameraRenderer.ts" />
<Content Include="renderers\canvas\CameraRenderer.js">
<DependentUpon>CameraRenderer.ts</DependentUpon>
</Content>
<Content Include="renderers\canvas\CanvasRenderer.js">
<DependentUpon>CanvasRenderer.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="renderers\canvas\GroupRenderer.ts" />
<TypeScriptCompile Include="renderers\canvas\GeometryRenderer.ts" />
<Content Include="renderers\canvas\GeometryRenderer.js">
<DependentUpon>GeometryRenderer.ts</DependentUpon>
</Content>
<Content Include="renderers\canvas\GroupRenderer.js">
<DependentUpon>GroupRenderer.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="renderers\canvas\ScrollZoneRenderer.ts" />
<Content Include="renderers\canvas\ScrollZoneRenderer.js">
<DependentUpon>ScrollZoneRenderer.ts</DependentUpon>
</Content>
<Content Include="renderers\canvas\SpriteRenderer.js">
<DependentUpon>SpriteRenderer.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="renderers\canvas\TilemapRenderer.ts" />
<Content Include="renderers\canvas\TilemapRenderer.js">
<DependentUpon>TilemapRenderer.ts</DependentUpon>
</Content>
<Content Include="renderers\HeadlessRenderer.js">
<DependentUpon>HeadlessRenderer.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="renderers\IRenderer.ts" />
<Content Include="renderers\IRenderer.js">
<DependentUpon>IRenderer.ts</DependentUpon>
</Content>
<Content Include="Statics.js">
<DependentUpon>Statics.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="system\screens\OrientationScreen.ts" />
<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\ColorUtils.ts" />
<Content Include="utils\ColorUtils.js">
<DependentUpon>ColorUtils.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="utils\DebugUtils.ts" />
<Content Include="utils\DebugUtils.js">
<DependentUpon>DebugUtils.ts</DependentUpon>
</Content>
<Content Include="utils\PointUtils.js">
<DependentUpon>PointUtils.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="utils\RectangleUtils.ts" />
<Content Include="utils\RectangleUtils.js">
<DependentUpon>RectangleUtils.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="math\Vec2Utils.ts" />
<Content Include="math\Vec2Utils.js">
<DependentUpon>Vec2Utils.ts</DependentUpon>
</Content>
<Content Include="sound\SoundManager.js">
<DependentUpon>SoundManager.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="system\screens\PauseScreen.ts" />
<TypeScriptCompile Include="system\screens\BootScreen.ts" />
<TypeScriptCompile Include="input\MSPointer.ts" />
<TypeScriptCompile Include="input\Gestures.ts" />
<Content Include="input\Gestures.js">
<DependentUpon>Gestures.ts</DependentUpon>
</Content>
<Content Include="input\MSPointer.js">
<DependentUpon>MSPointer.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="input\Pointer.ts" />
<Content Include="input\Pointer.js">
<DependentUpon>Pointer.ts</DependentUpon>
</Content>
<Content Include="system\screens\BootScreen.js">
<DependentUpon>BootScreen.ts</DependentUpon>
</Content>
<Content Include="system\screens\PauseScreen.js">
<DependentUpon>PauseScreen.ts</DependentUpon>
</Content>
<Content Include="sound\Sound.js">
<DependentUpon>Sound.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="sound\Sound.ts" />
<TypeScriptCompile Include="sound\SoundManager.ts" />
<Content Include="loader\AnimationLoader.js">
<DependentUpon>AnimationLoader.ts</DependentUpon>
</Content>
<Content Include="cameras\Camera.js">
<DependentUpon>Camera.ts</DependentUpon>
</Content>
<Content Include="system\Device.js">
<DependentUpon>Device.ts</DependentUpon>
</Content>
<Content Include="math\RandomDataGenerator.js">
<DependentUpon>RandomDataGenerator.ts</DependentUpon>
</Content>
<Content Include="system\RequestAnimationFrame.js">
<DependentUpon>RequestAnimationFrame.ts</DependentUpon>
</Content>
<Content Include="system\StageScaleMode.js">
<DependentUpon>StageScaleMode.ts</DependentUpon>
</Content>
<Content Include="tweens\Tween.js">
<DependentUpon>Tween.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="tweens\Tween.ts" />
<TypeScriptCompile Include="system\StageScaleMode.ts" />
<TypeScriptCompile Include="system\RequestAnimationFrame.ts" />
<TypeScriptCompile Include="math\RandomDataGenerator.ts" />
<TypeScriptCompile Include="system\Device.ts" />
<TypeScriptCompile Include="cameras\Camera.ts" />
<Content Include="tweens\easing\Back.js">
<DependentUpon>Back.ts</DependentUpon>
</Content>
<Content Include="tweens\easing\Bounce.js">
<DependentUpon>Bounce.ts</DependentUpon>
</Content>
<Content Include="tweens\easing\Circular.js">
<DependentUpon>Circular.ts</DependentUpon>
</Content>
<Content Include="tweens\easing\Cubic.js">
<DependentUpon>Cubic.ts</DependentUpon>
</Content>
<Content Include="tweens\easing\Elastic.js">
<DependentUpon>Elastic.ts</DependentUpon>
</Content>
<Content Include="tweens\easing\Exponential.js">
<DependentUpon>Exponential.ts</DependentUpon>
</Content>
<Content Include="tweens\easing\Linear.js">
<DependentUpon>Linear.ts</DependentUpon>
</Content>
<Content Include="tweens\easing\Quadratic.js">
<DependentUpon>Quadratic.ts</DependentUpon>
</Content>
<Content Include="tweens\easing\Quartic.js">
<DependentUpon>Quartic.ts</DependentUpon>
</Content>
<Content Include="tweens\easing\Quintic.js">
<DependentUpon>Quintic.ts</DependentUpon>
</Content>
<Content Include="tweens\easing\Sinusoidal.js">
<DependentUpon>Sinusoidal.ts</DependentUpon>
</Content>
<Content Include="input\Input.js">
<DependentUpon>Input.ts</DependentUpon>
</Content>
<Content Include="input\Keyboard.js">
<DependentUpon>Keyboard.ts</DependentUpon>
</Content>
<Content Include="input\Mouse.js">
<DependentUpon>Mouse.ts</DependentUpon>
</Content>
<Content Include="input\Touch.js">
<DependentUpon>Touch.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="input\Touch.ts" />
<TypeScriptCompile Include="input\Mouse.ts" />
<TypeScriptCompile Include="input\Keyboard.ts" />
<TypeScriptCompile Include="input\Input.ts" />
<TypeScriptCompile Include="tweens\easing\Sinusoidal.ts" />
<TypeScriptCompile Include="tweens\easing\Quintic.ts" />
<TypeScriptCompile Include="tweens\easing\Quartic.ts" />
<TypeScriptCompile Include="tweens\easing\Quadratic.ts" />
<TypeScriptCompile Include="tweens\easing\Linear.ts" />
<TypeScriptCompile Include="tweens\easing\Exponential.ts" />
<TypeScriptCompile Include="tweens\easing\Elastic.ts" />
<TypeScriptCompile Include="tweens\easing\Cubic.ts" />
<TypeScriptCompile Include="tweens\easing\Circular.ts" />
<TypeScriptCompile Include="tweens\easing\Bounce.ts" />
<TypeScriptCompile Include="tweens\easing\Back.ts" />
<TypeScriptCompile Include="loader\AnimationLoader.ts" />
<Content Include="core\Group.js">
<DependentUpon>Group.ts</DependentUpon>
</Content>
<Content Include="loader\Loader.js">
<DependentUpon>Loader.ts</DependentUpon>
</Content>
<Content Include="Phaser.js">
<DependentUpon>Phaser.ts</DependentUpon>
</Content>
<Content Include="core\Signal.js">
<DependentUpon>Signal.ts</DependentUpon>
</Content>
<Content Include="core\SignalBinding.js">
<DependentUpon>SignalBinding.ts</DependentUpon>
</Content>
<Content Include="Stage.js">
<DependentUpon>Stage.ts</DependentUpon>
</Content>
<Content Include="State.js">
<DependentUpon>State.ts</DependentUpon>
</Content>
<Content Include="tweens\TweenManager.js">
<DependentUpon>TweenManager.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="utils\SpriteUtils.ts" />
<Content Include="utils\SpriteUtils.js">
<DependentUpon>SpriteUtils.ts</DependentUpon>
</Content>
<Content Include="World.js">
<DependentUpon>World.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="World.ts" />
<TypeScriptCompile Include="tweens\TweenManager.ts" />
<TypeScriptCompile Include="State.ts" />
<TypeScriptCompile Include="Stage.ts" />
<TypeScriptCompile Include="core\SignalBinding.ts" />
<TypeScriptCompile Include="core\Signal.ts" />
<TypeScriptCompile Include="Phaser.ts" />
<TypeScriptCompile Include="loader\Loader.ts" />
<TypeScriptCompile Include="core\Group.ts" />
<TypeScriptCompile Include="math\GameMath.ts" />
<Content Include="loader\Cache.js">
<DependentUpon>Cache.ts</DependentUpon>
</Content>
<Content Include="cameras\CameraManager.js">
<DependentUpon>CameraManager.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="cameras\CameraManager.ts" />
<TypeScriptCompile Include="loader\Cache.ts" />
</ItemGroup>
<Import Project="$(VSToolsPath)\TypeScript\Microsoft.TypeScript.targets" />
<PropertyGroup>
<PostBuildEvent>cd $(ProjectDir)..\build
copy phaser.js ..\Tests\</PostBuildEvent>
copy phaser-debug.js ..\Tests\</PostBuildEvent>
</PropertyGroup>
</Project>

20
Phaser/Phaser.sln Normal file
View file

@ -0,0 +1,20 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Phaser", "Phaser.csproj", "{BB30C59B-5B34-4F7C-B5CC-8D49EA280EDA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{BB30C59B-5B34-4F7C-B5CC-8D49EA280EDA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BB30C59B-5B34-4F7C-B5CC-8D49EA280EDA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BB30C59B-5B34-4F7C-B5CC-8D49EA280EDA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BB30C59B-5B34-4F7C-B5CC-8D49EA280EDA}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View file

@ -1,3 +1,5 @@
/// <reference path="_definitions.ts" />
/**
* Phaser
* www.phaser.io

View file

@ -1,10 +1,4 @@
/// <reference path="Phaser.ts" />
/// <reference path="Game.ts" />
/// <reference path="display/CSS3Filters.ts" />
/// <reference path="system/StageScaleMode.ts" />
/// <reference path="system/screens/BootScreen.ts" />
/// <reference path="system/screens/PauseScreen.ts" />
/// <reference path="system/screens/OrientationScreen.ts" />
/// <reference path="_definitions.ts" />
/**
* Phaser - Stage
@ -74,7 +68,7 @@ module Phaser {
/**
* Local reference to Game.
*/
public game: Game;
public game: Phaser.Game;
/**
* Background color of the stage (defaults to black). Set via the public backgroundColor property.

View file

@ -1,4 +1,4 @@
/// <reference path="Game.ts" />
/// <reference path="_definitions.ts" />
/**
* Phaser - State
@ -14,7 +14,7 @@ module Phaser {
* State constructor
* Create a new <code>State</code>.
*/
constructor(game: Game) {
constructor(game: Phaser.Game) {
this.game = game;
@ -35,73 +35,73 @@ module Phaser {
/**
* Reference to Game.
*/
public game: Game;
public game: Phaser.Game;
/**
* Currently used camera.
* @type {Camera}
*/
public camera: Camera;
public camera: Phaser.Camera;
/**
* Reference to the assets cache.
* @type {Cache}
*/
public cache: Cache;
public cache: Phaser.Cache;
/**
* Reference to the GameObject Factory.
* @type {GameObjectFactory}
*/
public add: GameObjectFactory;
public add: Phaser.GameObjectFactory;
/**
* Reference to the input manager
* @type {Input}
*/
public input: InputManager;
public input: Phaser.InputManager;
/**
* Reference to the assets loader.
* @type {Loader}
*/
public load: Loader;
public load: Phaser.Loader;
/**
* Reference to the math helper.
* @type {GameMath}
*/
public math: GameMath;
public math: Phaser.GameMath;
/**
* Reference to the sound manager.
* @type {SoundManager}
*/
public sound: SoundManager;
public sound: Phaser.SoundManager;
/**
* Reference to the stage.
* @type {Stage}
*/
public stage: Stage;
public stage: Phaser.Stage;
/**
* Reference to game clock.
* @type {Time}
*/
public time: TimeManager;
public time: Phaser.TimeManager;
/**
* Reference to the tween manager.
* @type {TweenManager}
*/
public tweens: TweenManager;
public tweens: Phaser.TweenManager;
/**
* Reference to the world.
* @type {World}
*/
public world: World;
public world: Phaser.World;
// Override these in your own States

View file

@ -1,3 +1,5 @@
/// <reference path="_definitions.ts" />
module Phaser {
/**
@ -45,6 +47,7 @@ module Phaser {
static TILEMAP: number = 5;
static SCROLLZONE: number = 6;
static BUTTON: number = 7;
static DYNAMICTEXTURE: number = 8;
static GEOM_POINT: number = 0;
static GEOM_CIRCLE: number = 1;
@ -61,6 +64,16 @@ module Phaser {
static OUT_OF_BOUNDS_DESTROY: number = 1;
static OUT_OF_BOUNDS_PERSIST: number = 2;
/**
* Use with <code>sort()</code> to sort in ascending order.
*/
static SORT_ASCENDING: number = -1;
/**
* Use with <code>sort()</code> to sort in descending order.
*/
static SORT_DESCENDING: number = 1;
/**
* Flag used to allow GameObjects to collide on their left side
* @type {number}

View file

@ -1,8 +1,4 @@
/// <reference path="Game.ts" />
/// <reference path="cameras/CameraManager.ts" />
/// <reference path="core/Group.ts" />
/// <reference path="geom/Rectangle.ts" />
/// <reference path="physics/Manager.ts" />
/// <reference path="_definitions.ts" />
/**
* Phaser - World
@ -25,38 +21,38 @@ module Phaser {
* @param width {number} Width of the world bound.
* @param height {number} Height of the world bound.
*/
constructor(game: Game, width: number, height: number) {
constructor(game: Phaser.Game, width: number, height: number) {
this.game = game;
this.cameras = new CameraManager(this.game, 0, 0, width, height);
this.cameras = new Phaser.CameraManager(this.game, 0, 0, width, height);
this.bounds = new Rectangle(0, 0, width, height);
this.bounds = new Phaser.Rectangle(0, 0, width, height);
}
/**
* Local reference to Game.
*/
public game: Game;
public game: Phaser.Game;
/**
* Camera manager of this world.
* @type {CameraManager}
*/
public cameras: CameraManager;
public cameras: Phaser.CameraManager;
/**
* Object container stores every object created with `create*` methods.
* @type {Group}
*/
public group: Group;
public group: Phaser.Group;
/**
* Bound of this world that objects can not escape from.
* @type {Rectangle}
*/
public bounds: Rectangle;
public bounds: Phaser.Rectangle;
/**
* The Gravity of the World (defaults to 0,0, or no gravity at all)
@ -79,7 +75,7 @@ module Phaser {
*/
public boot() {
this.group = new Group(this.game, 0);
this.group = new Phaser.Group(this.game, 0);
}
@ -171,7 +167,7 @@ module Phaser {
*
* @returns {array} An array contains all the cameras.
*/
public getAllCameras(): Camera[] {
public getAllCameras(): Phaser.Camera[] {
return this.cameras.getAll();
}

113
Phaser/_definitions.ts Normal file
View file

@ -0,0 +1,113 @@
/// <reference path="Phaser.ts" />
/// <reference path="Statics.ts" />
/// <reference path="geom/Point.ts" />
/// <reference path="geom/Rectangle.ts" />
/// <reference path="geom/Circle.ts" />
/// <reference path="geom/Line.ts" />
/// <reference path="math/GameMath.ts" />
/// <reference path="math/Vec2.ts" />
/// <reference path="math/Vec2Utils.ts" />
/// <reference path="math/Mat3.ts" />
/// <reference path="math/Mat3Utils.ts" />
/// <reference path="math/QuadTree.ts" />
/// <reference path="math/LinkedList.ts" />
/// <reference path="math/RandomDataGenerator.ts" />
/// <reference path="core/Plugin.ts" />
/// <reference path="core/PluginManager.ts" />
/// <reference path="core/Signal.ts" />
/// <reference path="core/SignalBinding.ts" />
/// <reference path="core/Group.ts" />
/// <reference path="cameras/Camera.ts" />
/// <reference path="cameras/CameraManager.ts" />
/// <reference path="display/CSS3Filters.ts" />
/// <reference path="display/DynamicTexture.ts" />
/// <reference path="display/Texture.ts" />
/// <reference path="tweens/easing/Back.ts" />
/// <reference path="tweens/easing/Bounce.ts" />
/// <reference path="tweens/easing/Circular.ts" />
/// <reference path="tweens/easing/Cubic.ts" />
/// <reference path="tweens/easing/Elastic.ts" />
/// <reference path="tweens/easing/Exponential.ts" />
/// <reference path="tweens/easing/Linear.ts" />
/// <reference path="tweens/easing/Quadratic.ts" />
/// <reference path="tweens/easing/Quartic.ts" />
/// <reference path="tweens/easing/Quintic.ts" />
/// <reference path="tweens/easing/Sinusoidal.ts" />
/// <reference path="tweens/Tween.ts" />
/// <reference path="tweens/TweenManager.ts" />
/// <reference path="time/TimeManager.ts" />
/// <reference path="net/Net.ts" />
/// <reference path="input/Keyboard.ts" />
/// <reference path="input/Mouse.ts" />
/// <reference path="input/MSPointer.ts" />
/// <reference path="input/Touch.ts" />
/// <reference path="input/Pointer.ts" />
/// <reference path="input/InputHandler.ts" />
/// <reference path="input/InputManager.ts" />
/// <reference path="system/Device.ts" />
/// <reference path="system/RequestAnimationFrame.ts" />
/// <reference path="system/StageScaleMode.ts" />
/// <reference path="system/screens/BootScreen.ts" />
/// <reference path="system/screens/OrientationScreen.ts" />
/// <reference path="system/screens/PauseScreen.ts" />
/// <reference path="sound/SoundManager.ts" />
/// <reference path="sound/Sound.ts" />
/// <reference path="animation/Animation.ts" />
/// <reference path="animation/AnimationManager.ts" />
/// <reference path="animation/Frame.ts" />
/// <reference path="animation/FrameData.ts" />
/// <reference path="loader/Cache.ts" />
/// <reference path="loader/Loader.ts" />
/// <reference path="loader/AnimationLoader.ts" />
/// <reference path="tilemap/Tile.ts" />
/// <reference path="tilemap/Tilemap.ts" />
/// <reference path="tilemap/TilemapLayer.ts" />
/// <reference path="ui/Button.ts" />
/// <reference path="physics/arcade/Body.ts" />
/// <reference path="gameobjects/Events.ts" />
/// <reference path="gameobjects/Sprite.ts" />
/// <reference path="gameobjects/TransformManager.ts" />
/// <reference path="gameobjects/ScrollRegion.ts" />
/// <reference path="gameobjects/ScrollZone.ts" />
/// <reference path="gameobjects/IGameObject.ts" />
/// <reference path="gameobjects/GameObjectFactory.ts" />
/// <reference path="utils/CircleUtils.ts" />
/// <reference path="utils/ColorUtils.ts" />
/// <reference path="utils/PointUtils.ts" />
/// <reference path="utils/RectangleUtils.ts" />
/// <reference path="utils/SpriteUtils.ts" />
/// <reference path="utils/DebugUtils.ts" />
/// <reference path="renderers/IRenderer.ts" />
/// <reference path="renderers/HeadlessRenderer.ts" />
/// <reference path="renderers/canvas/CameraRenderer.ts" />
/// <reference path="renderers/canvas/GeometryRenderer.ts" />
/// <reference path="renderers/canvas/GroupRenderer.ts" />
/// <reference path="renderers/canvas/ScrollZoneRenderer.ts" />
/// <reference path="renderers/canvas/SpriteRenderer.ts" />
/// <reference path="renderers/canvas/TilemapRenderer.ts" />
/// <reference path="renderers/canvas/CanvasRenderer.ts" />
/// <reference path="World.ts" />
/// <reference path="Stage.ts" />
/// <reference path="State.ts" />
/// <reference path="Game.ts" />

View file

@ -1,4 +1,4 @@
/// <reference path="../Game.ts" />
/// <reference path="../_definitions.ts" />
/**
* Phaser - Animation
@ -43,7 +43,7 @@ module Phaser {
/**
* Local reference to Game.
*/
public game: Game;
public game: Phaser.Game;
/**
* Local private reference to its owner sprite.

View file

@ -1,9 +1,4 @@
/// <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" />
/// <reference path="../_definitions.ts" />
/**
* Phaser - AnimationManager
@ -33,7 +28,7 @@ module Phaser.Components {
/**
* Reference to Phaser.Game
*/
public game: Game;
public game: Phaser.Game;
/**
* Local private reference to its parent game object.

View file

@ -1,4 +1,4 @@
/// <reference path="../Game.ts" />
/// <reference path="../_definitions.ts" />
/**
* Phaser - Frame

View file

@ -1,4 +1,4 @@
/// <reference path="../Game.ts" />
/// <reference path="../_definitions.ts" />
/**
* Phaser - FrameData
@ -23,7 +23,7 @@ module Phaser {
/**
* Local frame container.
*/
private _frames: Frame[];
private _frames: Phaser.Frame[];
/**
* Local frameName<->index container.
@ -39,7 +39,7 @@ module Phaser {
* @param frame {Frame} The frame you want to add.
* @return {Frame} The frame you just added.
*/
public addFrame(frame: Frame): Frame {
public addFrame(frame: Phaser.Frame): Phaser.Frame {
frame.index = this._frames.length;
@ -75,7 +75,7 @@ module Phaser {
* @param name {string} Name of the frame you want to get.
* @return {Frame} The frame you want.
*/
public getFrameByName(name: string): Frame {
public getFrameByName(name: string): Phaser.Frame {
if (this._frameNames[name] !== '')
{
@ -93,7 +93,6 @@ module Phaser {
*/
public checkFrameName(name: string): boolean {
if (this._frameNames[name] == null)
{
return false;
@ -110,7 +109,7 @@ module Phaser {
* @param [output] {Frame[]} result will be added into this array.
* @return {Frame[]} Ranges of specific frames in an array.
*/
public getFrameRange(start: number, end: number, output: Frame[] = []): Frame[] {
public getFrameRange(start: number, end: number, output: Phaser.Frame[]= []): Phaser.Frame[] {
for (var i = start; i <= end; i++)
{
@ -164,7 +163,7 @@ module Phaser {
* Get all frames in this frame data.
* @return {Frame[]} All the frames in an array.
*/
public getAllFrames(): Frame[] {
public getAllFrames(): Phaser.Frame[] {
return this._frames;
}
@ -175,7 +174,7 @@ module Phaser {
*/
public getFrames(range: number[]) {
var output: Frame[] = [];
var output: Phaser.Frame[] = [];
for (var i = 0; i < range.length; i++)
{

View file

@ -1,11 +1,4 @@
/// <reference path="../Game.ts" />
/// <reference path="../geom/Point.ts" />
/// <reference path="../geom/Rectangle.ts" />
/// <reference path="../math/Vec2.ts" />
/// <reference path="../display/Texture.ts" />
/// <reference path="../gameobjects/TransformManager.ts" />
/// <reference path="../gameobjects/Sprite.ts" />
/// <reference path="../core/PluginManager.ts" />
/// <reference path="../_definitions.ts" />
/**
* Phaser - Camera
@ -70,7 +63,7 @@ module Phaser {
/**
* Local reference to Game.
*/
public game: Game;
public game: Phaser.Game;
/**
* The PluginManager for the Game

View file

@ -1,5 +1,4 @@
/// <reference path="../Game.ts" />
/// <reference path="Camera.ts" />
/// <reference path="../_definitions.ts" />
/**
* Phaser - CameraManager
@ -21,7 +20,7 @@ module Phaser {
* @param width {number} Width of the created camera.
* @param height {number} Height of the created camera.
*/
constructor(game: Game, x: number, y: number, width: number, height: number) {
constructor(game: Phaser.Game, x: number, y: number, width: number, height: number) {
this.game = game;
@ -37,12 +36,12 @@ module Phaser {
/**
* Local reference to Game.
*/
public game: Game;
public game: Phaser.Game;
/**
* Local container for storing cameras.
*/
private _cameras: Camera[];
private _cameras: Phaser.Camera[];
/**
* Local container for storing cameras array length.
@ -62,19 +61,19 @@ module Phaser {
/**
* Currently used camera.
*/
public current: Camera;
public current: Phaser.Camera;
/**
* The default created camera.
*/
public defaultCamera: Camera;
public defaultCamera: Phaser.Camera;
/**
* Get all the cameras.
*
* @returns {Camera[]} An array contains all the cameras.
*/
public getAll(): Camera[] {
public getAll(): Phaser.Camera[] {
return this._cameras;
}
@ -111,9 +110,9 @@ module Phaser {
* @param height {number} Height of the new camera.
* @returns {Camera} The newly created camera object.
*/
public addCamera(x: number, y: number, width: number, height: number): Camera {
public addCamera(x: number, y: number, width: number, height: number): Phaser.Camera {
var newCam: Camera = new Camera(this.game, this._cameraLength, x, y, width, height);
var newCam: Phaser.Camera = new Phaser.Camera(this.game, this._cameraLength, x, y, width, height);
this._cameraLength = this._cameras.push(newCam);
@ -148,7 +147,7 @@ module Phaser {
}
public swap(camera1: Camera, camera2: Camera, sort: boolean = true): boolean {
public swap(camera1: Phaser.Camera, camera2: Phaser.Camera, sort: boolean = true): boolean {
if (camera1.ID == camera2.ID)
{
@ -169,7 +168,7 @@ module Phaser {
}
public getCameraUnderPoint(x: number, y: number): Camera {
public getCameraUnderPoint(x: number, y: number): Phaser.Camera {
// Work through the cameras in reverse as they are rendered in array order
// Return the first camera we find matching the criteria
@ -192,7 +191,7 @@ module Phaser {
* @param {string} index The <code>string</code> name of the Camera variable you want to sort on. Default value is "z".
* @param {number} order A <code>Group</code> constant that defines the sort order. Possible values are <code>Group.ASCENDING</code> and <code>Group.DESCENDING</code>. Default value is <code>Group.ASCENDING</code>.
*/
public sort(index: string = 'z', order: number = Group.ASCENDING) {
public sort(index: string = 'z', order: number = Phaser.Types.SORT_ASCENDING) {
this._sortIndex = index;
this._sortOrder = order;

View file

@ -1,7 +1,4 @@
/// <reference path="../Game.ts" />
/// <reference path="../Statics.ts" />
/// <reference path="../display/Texture.ts" />
/// <reference path="../gameobjects/TransformManager.ts" />
/// <reference path="../_definitions.ts" />
/**
* Phaser - Group
@ -13,7 +10,7 @@ module Phaser {
export class Group {
constructor(game: Game, maxSize: number = 0) {
constructor(game: Phaser.Game, maxSize: number = 0) {
this.game = game;
this.type = Phaser.Types.GROUP;
@ -73,7 +70,7 @@ module Phaser {
/**
* Reference to the main game object
*/
public game: Game;
public game: Phaser.Game;
/**
* The type of game object.
@ -93,7 +90,7 @@ module Phaser {
/**
* The Group this Group is a child of (if any).
*/
public group: Group = null;
public group: Phaser.Group = null;
/**
* Optional texture used in the background of the Camera.
@ -102,8 +99,10 @@ module Phaser {
/**
* The transform component.
* WTF TypeScript, thank you very much for wasting a day of my time debugging just to find out setting the type barfs
*/
public transform: Phaser.Components.TransformManager;
//public transform: Phaser.Components.TransformManager;
public transform;
/**
* A boolean representing if the Group has been modified in any way via a scale, rotate, flip or skew.
@ -120,16 +119,6 @@ module Phaser {
*/
public visible: boolean;
/**
* Use with <code>sort()</code> to sort in ascending order.
*/
public static ASCENDING: number = -1;
/**
* Use with <code>sort()</code> to sort in descending order.
*/
public static DESCENDING: number = 1;
/**
* Array of all the objects that exist in this group.
*/
@ -229,7 +218,7 @@ module Phaser {
* Calls render on all members of this Group who have a status of visible=true and exists=true
* You can also call Object.render directly, which will bypass the visible/exists check.
*/
public render(camera: Camera) {
public render(camera: Phaser.Camera) {
if (camera.isHidden(this) == true)
{
@ -265,7 +254,7 @@ module Phaser {
* Calls render on all members of this Group regardless of their visible status and also ignores the camera blacklist.
* Use this when the Group objects render to hidden canvases for example.
*/
public directRender(camera: Camera) {
public directRender(camera: Phaser.Camera) {
this.game.renderer.groupRenderer.preRender(camera, this);
@ -302,9 +291,9 @@ module Phaser {
/**
* @private
*/
public set maxSize(Size: number) {
public set maxSize(size: number) {
this._maxSize = Size;
this._maxSize = size;
if (this._marker >= this._maxSize)
{
@ -419,8 +408,8 @@ module Phaser {
* @param [frame] {string|number} If the sprite uses an image from a texture atlas or sprite sheet you can pass the frame here. Either a number for a frame ID or a string for a frame name.
* @returns {Sprite} The newly created sprite object.
*/
public addNewSprite(x: number, y: number, key: string = '', frame = null): Sprite {
return <Sprite> this.add(new Sprite(this.game, x, y, key, frame));
public addNewSprite(x: number, y: number, key: string = '', frame = null): Phaser.Sprite {
return <Phaser.Sprite> this.add(new Phaser.Sprite(this.game, x, y, key, frame));
}
/**
@ -473,7 +462,7 @@ module Phaser {
*
* @return {any} A reference to the object that was created. Don't forget to cast it back to the Class you want (e.g. myObject = myGroup.recycle(myObjectClass) as myObjectClass;).
*/
public recycle(objectClass = null) {
public recycle(objectClass = null): any {
if (this._maxSize > 0)
{
@ -524,7 +513,7 @@ module Phaser {
*
* @return {Basic} The removed object.
*/
public remove(object, splice: boolean = false) {
public remove(object, splice: boolean = false): any {
//console.log('removing from group: ', object.name);
@ -566,7 +555,7 @@ module Phaser {
*
* @return {Basic} The new object.
*/
public replace(oldObject, newObject) {
public replace(oldObject, newObject): any {
this._i = this.members.indexOf(oldObject);
@ -709,7 +698,7 @@ module Phaser {
* @param {string} index The <code>string</code> name of the member variable you want to sort on. Default value is "z".
* @param {number} order A <code>Group</code> constant that defines the sort order. Possible values are <code>Group.ASCENDING</code> and <code>Group.DESCENDING</code>. Default value is <code>Group.ASCENDING</code>.
*/
public sort(index: string = 'z', order: number = Group.ASCENDING) {
public sort(index: string = 'z', order: number = Phaser.Types.SORT_ASCENDING) {
this._sortIndex = index;
this._sortOrder = order;
@ -867,7 +856,7 @@ module Phaser {
*
* @return {any} A <code>Basic</code> currently flagged as not existing.
*/
public getFirstAvailable(objectClass = null) {
public getFirstAvailable(objectClass = null): any {
this._i = 0;
@ -917,7 +906,7 @@ module Phaser {
*
* @return {Basic} A <code>Basic</code> currently flagged as existing.
*/
public getFirstExtant() {
public getFirstExtant(): any {
this._i = 0;
@ -941,7 +930,7 @@ module Phaser {
*
* @return {Basic} A <code>Basic</code> currently flagged as not dead.
*/
public getFirstAlive() {
public getFirstAlive(): any {
this._i = 0;
@ -965,7 +954,7 @@ module Phaser {
*
* @return {Basic} A <code>Basic</code> currently flagged as dead.
*/
public getFirstDead() {
public getFirstDead(): any {
this._i = 0;
@ -1055,7 +1044,7 @@ module Phaser {
*
* @return {Basic} A <code>Basic</code> from the members list.
*/
public getRandom(startIndex: number = 0, length: number = 0) {
public getRandom(startIndex: number = 0, length: number = 0): any {
if (length == 0)
{

View file

@ -1,4 +1,4 @@
/// <reference path="../Game.ts" />
/// <reference path="../_definitions.ts" />
/**
* Phaser - Plugin
@ -29,7 +29,7 @@ module Phaser {
/**
* Local reference to Game.
*/
public game: Game;
public game: Phaser.Game;
/**
* The object that owns this Plugin (i.e. Camera, Game, Stage, etc).

View file

@ -1,5 +1,4 @@
/// <reference path="../Game.ts" />
/// <reference path="Plugin.ts" />
/// <reference path="../_definitions.ts" />
/**
* Phaser - PluginManager
@ -22,7 +21,7 @@ module Phaser {
/**
* Local reference to Game.
*/
public game: Game;
public game: Phaser.Game;
/**
* The object that owns this PluginManager.

View file

@ -1,4 +1,4 @@
/// <reference path="SignalBinding.ts" />
/// <reference path="../_definitions.ts" />
/**
* Phaser - Signal

View file

@ -1,4 +1,4 @@
/// <reference path="Signal.ts" />
/// <reference path="../_definitions.ts" />
/**
* Phaser - SignalBinding

View file

@ -1,4 +1,4 @@
/// <reference path="../Game.ts" />
/// <reference path="../_definitions.ts" />
/**
* Phaser - Display - CSS3Filters

View file

@ -0,0 +1,250 @@
/// <reference path="../_definitions.ts" />
/**
* 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
* based on the contents of the texture at the time. This allows you to create powerful effects
* once and have them replicated across as many game objects as you like.
*/
var Phaser;
(function (Phaser) {
var DynamicTexture = (function () {
/**
* DynamicTexture constructor
* Create a new <code>DynamicTexture</code>.
*
* @param game {Phaser.Game} Current game instance.
* @param width {number} Init width of this texture.
* @param height {number} Init height of this texture.
*/
function DynamicTexture(game, width, height) {
this._sx = 0;
this._sy = 0;
this._sw = 0;
this._sh = 0;
this._dx = 0;
this._dy = 0;
this._dw = 0;
this._dh = 0;
/**
* You can set a globalCompositeOperation that will be applied before the render method is called on this Sprite.
* This is useful if you wish to apply an effect like 'lighten'.
* If this value is set it will call a canvas context save and restore before and after the render pass, so use it sparingly.
* Set to null to disable.
*/
this.globalCompositeOperation = null;
this.game = game;
this.type = Phaser.Types.DYNAMICTEXTURE;
this.canvas = document.createElement('canvas');
this.canvas.width = width;
this.canvas.height = height;
this.context = this.canvas.getContext('2d');
this.css3 = new Phaser.Display.CSS3Filters(this.canvas);
this.bounds = new Phaser.Rectangle(0, 0, width, height);
}
/**
* Get a color of a specific pixel.
* @param x {number} X position of the pixel in this texture.
* @param y {number} Y position of the pixel in this texture.
* @return {number} A native color value integer (format: 0xRRGGBB)
*/
DynamicTexture.prototype.getPixel = function (x, y) {
//r = imageData.data[0];
//g = imageData.data[1];
//b = imageData.data[2];
//a = imageData.data[3];
var imageData = this.context.getImageData(x, y, 1, 1);
return Phaser.ColorUtils.getColor(imageData.data[0], imageData.data[1], imageData.data[2]);
};
/**
* Get a color of a specific pixel (including alpha value).
* @param x {number} X position of the pixel in this texture.
* @param y {number} Y position of the pixel in this texture.
* @return A native color value integer (format: 0xAARRGGBB)
*/
DynamicTexture.prototype.getPixel32 = function (x, y) {
var imageData = this.context.getImageData(x, y, 1, 1);
return Phaser.ColorUtils.getColor32(imageData.data[3], imageData.data[0], imageData.data[1], imageData.data[2]);
};
/**
* Get pixels in array in a specific Rectangle.
* @param rect {Rectangle} The specific Rectangle.
* @returns {array} CanvasPixelArray.
*/
DynamicTexture.prototype.getPixels = function (rect) {
return this.context.getImageData(rect.x, rect.y, rect.width, rect.height);
};
/**
* Set color of a specific pixel.
* @param x {number} X position of the target pixel.
* @param y {number} Y position of the target pixel.
* @param color {number} Native integer with color value. (format: 0xRRGGBB)
*/
DynamicTexture.prototype.setPixel = function (x, y, color) {
this.context.fillStyle = color;
this.context.fillRect(x, y, 1, 1);
};
/**
* Set color (with alpha) of a specific pixel.
* @param x {number} X position of the target pixel.
* @param y {number} Y position of the target pixel.
* @param color {number} Native integer with color value. (format: 0xAARRGGBB)
*/
DynamicTexture.prototype.setPixel32 = function (x, y, color) {
this.context.fillStyle = color;
this.context.fillRect(x, y, 1, 1);
};
/**
* Set image data to a specific Rectangle.
* @param rect {Rectangle} Target Rectangle.
* @param input {object} Source image data.
*/
DynamicTexture.prototype.setPixels = function (rect, input) {
this.context.putImageData(input, rect.x, rect.y);
};
/**
* Fill a given Rectangle with specific color.
* @param rect {Rectangle} Target Rectangle you want to fill.
* @param color {number} A native number with color value. (format: 0xRRGGBB)
*/
DynamicTexture.prototype.fillRect = function (rect, color) {
this.context.fillStyle = color;
this.context.fillRect(rect.x, rect.y, rect.width, rect.height);
};
/**
*
*/
DynamicTexture.prototype.pasteImage = function (key, frame, destX, destY, destWidth, destHeight) {
if (typeof frame === "undefined") { frame = -1; }
if (typeof destX === "undefined") { destX = 0; }
if (typeof destY === "undefined") { destY = 0; }
if (typeof destWidth === "undefined") { destWidth = null; }
if (typeof destHeight === "undefined") { destHeight = null; }
var texture = null;
var frameData;
this._sx = 0;
this._sy = 0;
this._dx = destX;
this._dy = destY;
if (frame > -1) {
//if (this.game.cache.isSpriteSheet(key))
//{
// texture = this.game.cache.getImage(key);
//this.animations.loadFrameData(this.game.cache.getFrameData(key));
//}
} else {
texture = this.game.cache.getImage(key);
this._sw = texture.width;
this._sh = texture.height;
this._dw = texture.width;
this._dh = texture.height;
}
if (destWidth !== null) {
this._dw = destWidth;
}
if (destHeight !== null) {
this._dh = destHeight;
}
if (texture != null) {
this.context.drawImage(texture, this._sx, this._sy, this._sw, this._sh, this._dx, this._dy, this._dw, this._dh);
}
};
// TODO - Add in support for: alphaBitmapData: BitmapData = null, alphaPoint: Point = null, mergeAlpha: boolean = false
/**
* Copy pixel from another DynamicTexture to this texture.
* @param sourceTexture {DynamicTexture} Source texture object.
* @param sourceRect {Rectangle} The specific region Rectangle to be copied to this in the source.
* @param destPoint {Point} Top-left point the target image data will be paste at.
*/
DynamicTexture.prototype.copyPixels = function (sourceTexture, sourceRect, destPoint) {
if (Phaser.RectangleUtils.equals(sourceRect, this.bounds) == true) {
this.context.drawImage(sourceTexture.canvas, destPoint.x, destPoint.y);
} else {
this.context.putImageData(sourceTexture.getPixels(sourceRect), destPoint.x, destPoint.y);
}
};
DynamicTexture.prototype.add = function (sprite) {
sprite.texture.canvas = this.canvas;
sprite.texture.context = this.context;
};
/**
* Given an array of Sprites it will update each of them so that their canvas/contexts reference this DynamicTexture
* @param objects {Array} An array of GameObjects, or objects that inherit from it such as Sprites
*/
DynamicTexture.prototype.assignCanvasToGameObjects = function (objects) {
for (var i = 0; i < objects.length; i++) {
if (objects[i].texture) {
objects[i].texture.canvas = this.canvas;
objects[i].texture.context = this.context;
}
}
};
/**
* Clear the whole canvas.
*/
DynamicTexture.prototype.clear = function () {
this.context.clearRect(0, 0, this.bounds.width, this.bounds.height);
};
/**
* Renders this DynamicTexture to the Stage at the given x/y coordinates
*
* @param x {number} The X coordinate to render on the stage to (given in screen coordinates, not world)
* @param y {number} The Y coordinate to render on the stage to (given in screen coordinates, not world)
*/
DynamicTexture.prototype.render = function (x, y) {
if (typeof x === "undefined") { x = 0; }
if (typeof y === "undefined") { y = 0; }
if (this.globalCompositeOperation) {
this.game.stage.context.save();
this.game.stage.context.globalCompositeOperation = this.globalCompositeOperation;
}
this.game.stage.context.drawImage(this.canvas, x, y);
if (this.globalCompositeOperation) {
this.game.stage.context.restore();
}
};
Object.defineProperty(DynamicTexture.prototype, "width", {
get: function () {
return this.bounds.width;
},
enumerable: true,
configurable: true
});
Object.defineProperty(DynamicTexture.prototype, "height", {
get: function () {
return this.bounds.height;
},
enumerable: true,
configurable: true
});
return DynamicTexture;
})();
Phaser.DynamicTexture = DynamicTexture;
})(Phaser || (Phaser = {}));

View file

@ -1,6 +1,4 @@
/// <reference path="../Game.ts" />
/// <reference path="../utils/RectangleUtils.ts" />
/// <reference path="../utils/ColorUtils.ts" />
/// <reference path="../_definitions.ts" />
/**
* Phaser - Display - DynamicTexture
@ -11,7 +9,7 @@
* once and have them replicated across as many game objects as you like.
*/
module Phaser {
module Phaser.Display {
export class DynamicTexture {
@ -26,7 +24,7 @@ module Phaser {
constructor(game: Game, width: number, height: number) {
this.game = game;
this.type = Phaser.Types.GEOMSPRITE;
this.type = Phaser.Types.DYNAMICTEXTURE;
this.canvas = <HTMLCanvasElement> document.createElement('canvas');
this.canvas.width = width;
@ -42,7 +40,7 @@ module Phaser {
/**
* Reference to game.
*/
public game: Game;
public game: Phaser.Game;
/**
* The type of game object.
@ -71,7 +69,7 @@ module Phaser {
* Bound of this texture with width and height info.
* @type {Rectangle}
*/
public bounds: Rectangle;
public bounds: Phaser.Rectangle;
/**
* This class is actually a wrapper of canvas.
@ -107,7 +105,7 @@ module Phaser {
//a = imageData.data[3];
var imageData = this.context.getImageData(x, y, 1, 1);
return ColorUtils.getColor(imageData.data[0], imageData.data[1], imageData.data[2]);
return Phaser.ColorUtils.getColor(imageData.data[0], imageData.data[1], imageData.data[2]);
}
@ -121,7 +119,7 @@ module Phaser {
var imageData = this.context.getImageData(x, y, 1, 1);
return ColorUtils.getColor32(imageData.data[3], imageData.data[0], imageData.data[1], imageData.data[2]);
return Phaser.ColorUtils.getColor32(imageData.data[3], imageData.data[0], imageData.data[1], imageData.data[2]);
}
@ -130,7 +128,7 @@ module Phaser {
* @param rect {Rectangle} The specific Rectangle.
* @returns {array} CanvasPixelArray.
*/
public getPixels(rect: Rectangle) {
public getPixels(rect: Phaser.Rectangle) {
return this.context.getImageData(rect.x, rect.y, rect.width, rect.height);
@ -167,7 +165,7 @@ module Phaser {
* @param rect {Rectangle} Target Rectangle.
* @param input {object} Source image data.
*/
public setPixels(rect: Rectangle, input) {
public setPixels(rect: Phaser.Rectangle, input) {
this.context.putImageData(input, rect.x, rect.y);
@ -178,7 +176,7 @@ module Phaser {
* @param rect {Rectangle} Target Rectangle you want to fill.
* @param color {number} A native number with color value. (format: 0xRRGGBB)
*/
public fillRect(rect: Rectangle, color: number) {
public fillRect(rect: Phaser.Rectangle, color: number) {
this.context.fillStyle = color;
this.context.fillRect(rect.x, rect.y, rect.width, rect.height);
@ -250,7 +248,7 @@ module Phaser {
* @param sourceRect {Rectangle} The specific region Rectangle to be copied to this in the source.
* @param destPoint {Point} Top-left point the target image data will be paste at.
*/
public copyPixels(sourceTexture: DynamicTexture, sourceRect: Rectangle, destPoint: Point) {
public copyPixels(sourceTexture: Phaser.Display.DynamicTexture, sourceRect: Phaser.Rectangle, destPoint: Phaser.Point) {
// Swap for drawImage if the sourceRect is the same size as the sourceTexture to avoid a costly getImageData call
if (Phaser.RectangleUtils.equals(sourceRect, this.bounds) == true)
@ -264,7 +262,7 @@ module Phaser {
}
public add(sprite: Sprite) {
public add(sprite: Phaser.Sprite) {
sprite.texture.canvas = this.canvas;
sprite.texture.context = this.context;

View file

@ -1,6 +1,4 @@
/// <reference path="../Game.ts" />
/// <reference path="../utils/SpriteUtils.ts" />
/// <reference path="DynamicTexture.ts" />
/// <reference path="../_definitions.ts" />
/**
* Phaser - Display - Texture
@ -54,7 +52,7 @@ module Phaser.Display {
/**
* Reference to Phaser.Game
*/
public game: Game;
public game: Phaser.Game;
/**
* Reference to the parent object (Sprite, Group, etc)
@ -70,7 +68,7 @@ module Phaser.Display {
* Reference to the DynamicTexture that is used as the texture for the Sprite.
* @type {DynamicTexture}
*/
public dynamicTexture: DynamicTexture = null;
public dynamicTexture: Phaser.Display.DynamicTexture = null;
/**
* The load status of the texture image.
@ -178,7 +176,7 @@ module Phaser.Display {
*
* @param object {Camera} The camera this object should ignore.
*/
public hideFromCamera(camera: Camera) {
public hideFromCamera(camera: Phaser.Camera) {
if (this.isHidden(camera) == false)
{
@ -191,7 +189,7 @@ module Phaser.Display {
/**
* Returns true if this texture is hidden from rendering to the given camera, otherwise false.
*/
public isHidden(camera: Camera): boolean {
public isHidden(camera: Phaser.Camera): boolean {
if (this._blacklist && this.cameraBlacklist.indexOf(camera.ID) !== -1)
{
@ -208,7 +206,7 @@ module Phaser.Display {
*
* @param object {Sprite/Group} The object this camera should display.
*/
public showToCamera(camera: Camera) {
public showToCamera(camera: Phaser.Camera) {
if (this.isHidden(camera))
{
@ -222,7 +220,7 @@ module Phaser.Display {
* Updates the texture being used to render the Sprite.
* Called automatically by SpriteUtils.loadTexture and SpriteUtils.loadDynamicTexture.
*/
public setTo(image = null, dynamic: DynamicTexture = null) {
public setTo(image = null, dynamic: Phaser.Display.DynamicTexture = null) {
if (dynamic)
{

View file

@ -1,4 +1,4 @@
/// <reference path="../Game.ts" />
/// <reference path="../_definitions.ts" />
/**
* Phaser - Components - Events
@ -30,7 +30,7 @@ module Phaser.Components {
/**
* Reference to Phaser.Game
*/
public game: Game;
public game: Phaser.Game;
/**
* Local private reference to its parent game object.

View file

@ -1,12 +1,4 @@
/// <reference path="../Game.ts" />
/// <reference path="../tweens/Tween.ts" />
/// <reference path="../particles/ArcadeEmitter.ts" />
/// <reference path="../particles/ArcadeParticle.ts" />
/// <reference path="../gameobjects/Sprite.ts" />
/// <reference path="../ui/Button.ts" />
/// <reference path="../gameobjects/ScrollZone.ts" />
/// <reference path="../display/DynamicTexture.ts" />
/// <reference path="../tilemap/Tilemap.ts" />
/// <reference path="../_definitions.ts" />
/**
* Phaser - GameObjectFactory
@ -48,7 +40,7 @@ module Phaser {
* @param height {number} Height of the new camera.
* @returns {Camera} The newly created camera object.
*/
public camera(x: number, y: number, width: number, height: number): Camera {
public camera(x: number, y: number, width: number, height: number): Phaser.Camera {
return this._world.cameras.addCamera(x, y, width, height);
}
@ -76,8 +68,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): UI.Button {
return <UI.Button> this._world.group.add(new UI.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): Phaser.UI.Button {
return <Phaser.UI.Button> this._world.group.add(new Phaser.UI.Button(this.game, x, y, key, callback, callbackContext, overFrame, outFrame, downFrame));
}
/**
@ -89,12 +81,12 @@ module Phaser {
* @param [frame] {string|number} If the sprite uses an image from a texture atlas or sprite sheet you can pass the frame here. Either a number for a frame ID or a string for a frame name.
* @returns {Sprite} The newly created sprite object.
*/
public sprite(x: number, y: number, key: string = '', frame = null): Sprite {
return <Sprite> this._world.group.add(new Sprite(this.game, x, y, key, frame));
public sprite(x: number, y: number, key: string = '', frame = null): Phaser.Sprite {
return <Phaser.Sprite> this._world.group.add(new Phaser.Sprite(this.game, x, y, key, frame));
}
public audio(key: string, volume: number = 1, loop: boolean = false) {
return <Sound> this.game.sound.add(key, volume, loop);
public audio(key: string, volume: number = 1, loop: boolean = false): Phaser.Sound {
return <Phaser.Sound> this.game.sound.add(key, volume, loop);
}
/**
@ -119,8 +111,8 @@ module Phaser {
* @param height {number} Height of the texture.
* @returns {DynamicTexture} The newly created dynamic texture object.
*/
public dynamicTexture(width: number, height: number): DynamicTexture {
return new DynamicTexture(this.game, width, height);
public dynamicTexture(width: number, height: number): Phaser.Display.DynamicTexture {
return new Phaser.Display.DynamicTexture(this.game, width, height);
}
/**
@ -129,8 +121,8 @@ module Phaser {
* @param maxSize {number} Optional, capacity of this group.
* @returns {Group} The newly created group.
*/
public group(maxSize: number = 0): Group {
return <Group> this._world.group.add(new Group(this.game, maxSize));
public group(maxSize: number = 0): Phaser.Group {
return <Phaser.Group> this._world.group.add(new Phaser.Group(this.game, maxSize));
}
/**
@ -138,9 +130,9 @@ module Phaser {
*
* @return {Particle} The newly created particle object.
*/
public particle(): ArcadeParticle {
return new ArcadeParticle(this.game);
}
//public particle(): ArcadeParticle {
// return new ArcadeParticle(this.game);
//}
/**
* Create a new Emitter.
@ -150,9 +142,9 @@ 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): ArcadeEmitter {
return <ArcadeEmitter> this._world.group.add(new ArcadeEmitter(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));
//}
/**
* Create a new ScrollZone object with image key, position and size.
@ -164,8 +156,8 @@ module Phaser {
* @param height {number} Height of this object.
* @returns {ScrollZone} The newly created scroll zone object.
*/
public scrollZone(key: string, x: number = 0, y: number = 0, width: number = 0, height: number = 0): ScrollZone {
return <ScrollZone> this._world.group.add(new ScrollZone(this.game, key, x, y, width, height));
public scrollZone(key: string, x: number = 0, y: number = 0, width: number = 0, height: number = 0): Phaser.ScrollZone {
return <Phaser.ScrollZone> this._world.group.add(new Phaser.ScrollZone(this.game, key, x, y, width, height));
}
/**
@ -179,8 +171,8 @@ module Phaser {
* @param [tileHeight] {number} height of each tile.
* @return {Tilemap} The newly created tilemap object.
*/
public tilemap(key: string, mapData: string, format: number, resizeWorld: boolean = true, tileWidth: number = 0, tileHeight: number = 0): Tilemap {
return <Tilemap> this._world.group.add(new Tilemap(this.game, key, mapData, format, resizeWorld, tileWidth, tileHeight));
public tilemap(key: string, mapData: string, format: number, resizeWorld: boolean = true, tileWidth: number = 0, tileHeight: number = 0): Phaser.Tilemap {
return <Phaser.Tilemap> this._world.group.add(new Phaser.Tilemap(this.game, key, mapData, format, resizeWorld, tileWidth, tileHeight));
}
/**
@ -190,7 +182,7 @@ module Phaser {
* @param [localReference] {bool} If true the tween will be stored in the object.tween property so long as it exists. If already set it'll be over-written.
* @return {Phaser.Tween} The newly created tween object.
*/
public tween(obj, localReference:boolean = false): Tween {
public tween(obj, localReference: boolean = false): Phaser.Tween {
return this.game.tweens.create(obj, localReference);
}
@ -201,7 +193,7 @@ module Phaser {
* @param sprite The Sprite to add to the Game World
* @return {Phaser.Sprite} The Sprite object
*/
public existingSprite(sprite: Sprite): Sprite {
public existingSprite(sprite: Phaser.Sprite): Phaser.Sprite {
return this._world.group.add(sprite);
}
@ -212,7 +204,7 @@ module Phaser {
* @param group The Group to add to the Game World
* @return {Phaser.Group} The Group object
*/
public existingGroup(group: Group): Group {
public existingGroup(group: Phaser.Group): Phaser.Group {
return this._world.group.add(group);
}
@ -223,7 +215,7 @@ module Phaser {
* @param button The Button to add to the Game World
* @return {Phaser.Button} The Button object
*/
public existingButton(button: UI.Button): UI.Button {
public existingButton(button: Phaser.UI.Button): Phaser.UI.Button {
return this._world.group.add(button);
}
@ -245,9 +237,9 @@ module Phaser {
* @param emitter The Emitter to add to the Game World
* @return {Phaser.Emitter} The Emitter object
*/
public existingEmitter(emitter: ArcadeEmitter): ArcadeEmitter {
return this._world.group.add(emitter);
}
//public existingEmitter(emitter: ArcadeEmitter): ArcadeEmitter {
// return this._world.group.add(emitter);
//}
/**
* Add an existing ScrollZone to the current world.
@ -256,7 +248,7 @@ module Phaser {
* @param scrollZone The ScrollZone to add to the Game World
* @return {Phaser.ScrollZone} The ScrollZone object
*/
public existingScrollZone(scrollZone: ScrollZone): ScrollZone {
public existingScrollZone(scrollZone: Phaser.ScrollZone): Phaser.ScrollZone {
return this._world.group.add(scrollZone);
}
@ -267,7 +259,7 @@ module Phaser {
* @param tilemap The Tilemap to add to the Game World
* @return {Phaser.Tilemap} The Tilemap object
*/
public existingTilemap(tilemap: Tilemap): Tilemap {
public existingTilemap(tilemap: Phaser.Tilemap): Phaser.Tilemap {
return this._world.group.add(tilemap);
}
@ -278,7 +270,7 @@ module Phaser {
* @param tween The Tween to add to the Game World
* @return {Phaser.Tween} The Tween object
*/
public existingTween(tween: Tween): Tween {
public existingTween(tween: Phaser.Tween): Phaser.Tween {
return this.game.tweens.add(tween);
}

View file

@ -1,4 +1,4 @@
/// <reference path="../Game.ts" />
/// <reference path="../_definitions.ts" />
module Phaser {
@ -7,7 +7,7 @@ module Phaser {
/**
* Reference to the main game object
*/
game: Game;
game: Phaser.Game;
/**
* The type of game object.
@ -17,7 +17,7 @@ module Phaser {
/**
* The ID of the Group this Sprite belongs to.
*/
group: Group;
group: Phaser.Group;
/**
* The name of the Game Object. Typically not set by Phaser, but extremely useful for debugging / logic.
@ -62,12 +62,12 @@ module Phaser {
/**
* Associated events
*/
events;
events: Phaser.Components.Events;
/**
* The input component
*/
input;
input: Phaser.Components.InputHandler;
/**
* The texture used to render.

View file

@ -1,6 +1,4 @@
/// <reference path="../Game.ts" />
/// <reference path="../geom/Rectangle.ts" />
/// <reference path="../math/Vec2.ts" />
/// <reference path="../_definitions.ts" />
/**
* Phaser - ScrollRegion

View file

@ -1,6 +1,4 @@
/// <reference path="../Game.ts" />
/// <reference path="../geom/Rectangle.ts" />
/// <reference path="ScrollRegion.ts" />
/// <reference path="../_definitions.ts" />
/**
* Phaser - ScrollZone
@ -62,13 +60,13 @@ module Phaser {
* Current region this zone is scrolling.
* @type {ScrollRegion}
*/
public currentRegion: ScrollRegion;
public currentRegion: Phaser.ScrollRegion;
/**
* Array contains all added regions.
* @type {ScrollRegion[]}
*/
public regions: ScrollRegion[];
public regions: Phaser.ScrollRegion[];
/**
* Add a new region to this zone.
@ -80,7 +78,7 @@ module Phaser {
* @param [speedY] {number} y-axis scrolling speed.
* @return {ScrollRegion} The newly added region.
*/
public addRegion(x: number, y: number, width: number, height: number, speedX:number = 0, speedY:number = 0):ScrollRegion {
public addRegion(x: number, y: number, width: number, height: number, speedX: number = 0, speedY: number = 0): Phaser.ScrollRegion {
if (x > this.width || y > this.height || x < 0 || y < 0 || (x + width) > this.width || (y + height) > this.height)
{
@ -88,7 +86,7 @@ module Phaser {
return null;
}
this.currentRegion = new ScrollRegion(x, y, width, height, speedX, speedY);
this.currentRegion = new Phaser.ScrollRegion(x, y, width, height, speedX, speedY);
this.regions.push(this.currentRegion);
@ -134,7 +132,7 @@ module Phaser {
var tileWidth = Math.ceil(this.width / regionWidth) * regionWidth;
var tileHeight = Math.ceil(this.height / regionHeight) * regionHeight;
var dt: DynamicTexture = new DynamicTexture(this.game, tileWidth, tileHeight);
var dt: Phaser.Display.DynamicTexture = new Phaser.Display.DynamicTexture(this.game, tileWidth, tileHeight);
dt.context.rect(0, 0, tileWidth, tileHeight);
dt.context.fillStyle = dt.context.createPattern(this.texture.imageTexture, "repeat");

View file

@ -1,12 +1,4 @@
/// <reference path="../Game.ts" />
/// <reference path="../math/Vec2.ts" />
/// <reference path="../geom/Rectangle.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" />
/// <reference path="../_definitions.ts" />
/**
* Phaser - Sprite
@ -86,7 +78,7 @@ module Phaser {
/**
* Reference to the main game object
*/
public game: Game;
public game: Phaser.Game;
/**
* The type of game object.
@ -101,7 +93,7 @@ module Phaser {
/**
* The Group this Sprite belongs to.
*/
public group: Group;
public group: Phaser.Group;
/**
* Controls if both <code>update</code> and render are called by the core game loop.
@ -137,7 +129,8 @@ module Phaser {
/**
* Sprite physics body.
*/
public body: Phaser.Physics.Body = null;
//public body: Phaser.Physics.Body = null;
public body;
/**
* The texture used to render the Sprite.
@ -236,7 +229,7 @@ module Phaser {
if (this.group)
{
this.group.bringToTop(this);
//this.group.bringToTop(this);
}
}
@ -426,7 +419,7 @@ module Phaser {
if (removeFromGroup && this.group)
{
this.group.remove(this);
//this.group.remove(this);
}
this.events.onKilled.dispatch(this);

View file

@ -1,6 +1,4 @@
/// <reference path="../Game.ts" />
/// <reference path="../math/Mat3.ts" />
/// <reference path="../geom/Point.ts" />
/// <reference path="../_definitions.ts" />
/**
* Phaser - Components - TransformManager
@ -19,7 +17,7 @@ module Phaser.Components {
this.game = parent.game;
this.parent = parent;
this.local = new Mat3;
this.local = new Phaser.Mat3;
this.scrollFactor = new Phaser.Vec2(1, 1);
this.origin = new Phaser.Vec2;
@ -63,7 +61,7 @@ module Phaser.Components {
/**
* Reference to Phaser.Game
*/
public game: Game;
public game: Phaser.Game;
/**
* Reference to the parent object (Sprite, Group, etc)
@ -73,22 +71,22 @@ module Phaser.Components {
/**
* Scale of the object. A scale of 1.0 is the original size. 0.5 half size. 2.0 double sized.
*/
public scale: Vec2;
public scale: Phaser.Vec2;
/**
* Skew the object along the x and y axis. A skew value of 0 is no skew.
*/
public skew: Vec2;
public skew: Phaser.Vec2;
/**
* The influence of camera movement upon the object, if supported.
*/
public scrollFactor: Vec2;
public scrollFactor: Phaser.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;
public origin: Phaser.Vec2;
/**
* This value is added to the rotation of the object.
@ -131,7 +129,7 @@ module Phaser.Components {
/**
* The local transform matrix
*/
public local: Mat3;
public local: Phaser.Mat3;
/**
* The distance from the center of the transform to the rotation origin.
@ -220,16 +218,16 @@ module Phaser.Components {
this._size.y = this.parent.height;
this._origin.x = this.origin.x;
this._origin.y = this.origin.y;
this._sc.x = Math.sin((this.rotation + this.rotationOffset) * GameMath.DEG_TO_RAD);
this._sc.y = Math.cos((this.rotation + this.rotationOffset) * GameMath.DEG_TO_RAD);
this._scA.y = Math.cos((this.rotation + this.rotationOffset) * GameMath.DEG_TO_RAD + this._angle);
this._scA.x = Math.sin((this.rotation + this.rotationOffset) * GameMath.DEG_TO_RAD + this._angle);
this._sc.x = Math.sin((this.rotation + this.rotationOffset) * Phaser.GameMath.DEG_TO_RAD);
this._sc.y = Math.cos((this.rotation + this.rotationOffset) * Phaser.GameMath.DEG_TO_RAD);
this._scA.y = Math.cos((this.rotation + this.rotationOffset) * Phaser.GameMath.DEG_TO_RAD + this._angle);
this._scA.x = Math.sin((this.rotation + this.rotationOffset) * Phaser.GameMath.DEG_TO_RAD + this._angle);
this._prevRotation = this.rotation;
if (this.parent.texture && this.parent.texture.renderRotation)
{
this._sc.x = Math.sin((this.rotation + this.rotationOffset) * GameMath.DEG_TO_RAD);
this._sc.y = Math.cos((this.rotation + this.rotationOffset) * GameMath.DEG_TO_RAD);
this._sc.x = Math.sin((this.rotation + this.rotationOffset) * Phaser.GameMath.DEG_TO_RAD);
this._sc.y = Math.cos((this.rotation + this.rotationOffset) * Phaser.GameMath.DEG_TO_RAD);
}
else
{
@ -278,15 +276,15 @@ module Phaser.Components {
// 2) Rotation change
if (this.rotation != this._prevRotation)
{
this._sc.x = Math.sin((this.rotation + this.rotationOffset) * GameMath.DEG_TO_RAD);
this._sc.y = Math.cos((this.rotation + this.rotationOffset) * GameMath.DEG_TO_RAD);
this._scA.y = Math.cos((this.rotation + this.rotationOffset) * GameMath.DEG_TO_RAD + this._angle);
this._scA.x = Math.sin((this.rotation + this.rotationOffset) * GameMath.DEG_TO_RAD + this._angle);
this._sc.x = Math.sin((this.rotation + this.rotationOffset) * Phaser.GameMath.DEG_TO_RAD);
this._sc.y = Math.cos((this.rotation + this.rotationOffset) * Phaser.GameMath.DEG_TO_RAD);
this._scA.y = Math.cos((this.rotation + this.rotationOffset) * Phaser.GameMath.DEG_TO_RAD + this._angle);
this._scA.x = Math.sin((this.rotation + this.rotationOffset) * Phaser.GameMath.DEG_TO_RAD + this._angle);
if (this.parent.texture.renderRotation)
{
this._sc.x = Math.sin((this.rotation + this.rotationOffset) * GameMath.DEG_TO_RAD);
this._sc.y = Math.cos((this.rotation + this.rotationOffset) * GameMath.DEG_TO_RAD);
this._sc.x = Math.sin((this.rotation + this.rotationOffset) * Phaser.GameMath.DEG_TO_RAD);
this._sc.y = Math.cos((this.rotation + this.rotationOffset) * Phaser.GameMath.DEG_TO_RAD);
}
else
{

View file

@ -1,4 +1,4 @@
/// <reference path="../Game.ts" />
/// <reference path="../_definitions.ts" />
/**
* Phaser - Circle

View file

@ -1,4 +1,4 @@
/// <reference path="../Game.ts" />
/// <reference path="../_definitions.ts" />
/**
* Phaser - Line
@ -239,7 +239,7 @@ module Phaser {
* @param {Any} line
* @return {Any}
*/
public intersectLineLine(line): any {
public intersectLineLine(line) {
//return Phaser.intersectLineLine(this,line);
}

View file

@ -1,4 +1,4 @@
/// <reference path="../Game.ts" />
/// <reference path="../_definitions.ts" />
/**
* Phaser - Point

View file

@ -1,4 +1,4 @@
/// <reference path="Point.ts" />
/// <reference path="../_definitions.ts" />
/**
* Rectangle

View file

@ -1,63 +0,0 @@
/// <reference path="../Game.ts" />
/// <reference path="Pointer.ts" />
/**
* Phaser - Gestures
*
* The Gesture class monitors for gestures and dispatches the resulting signals when they occur.
* Note: Android 2.x only supports 1 touch event at once, no multi-touch
*/
module Phaser {
export class Gestures {
/**
* Constructor
* @param {Game} game.
* @return {Touch} This object.
*/
constructor(game: Game) {
this.game = game;
}
/**
* Local reference to Game.
* @property _game
* @type {Game}
* @private
**/
public game: Game;
private _p1: Pointer;
private _p2: Pointer;
private _p3: Pointer;
private _p4: Pointer;
private _p5: Pointer;
private _p6: Pointer;
private _p7: Pointer;
private _p8: Pointer;
private _p9: Pointer;
private _p10: Pointer;
public start() {
// Local references to the Phaser.Input.pointer objects
this._p1 = this.game.input.pointer1;
this._p2 = this.game.input.pointer2;
this._p3 = this.game.input.pointer3;
this._p4 = this.game.input.pointer4;
this._p5 = this.game.input.pointer5;
this._p6 = this.game.input.pointer6;
this._p7 = this.game.input.pointer7;
this._p8 = this.game.input.pointer8;
this._p9 = this.game.input.pointer9;
this._p10 = this.game.input.pointer10;
}
}
}

View file

View file

@ -1,6 +1,4 @@
/// <reference path="../Game.ts" />
/// <reference path="../utils/SpriteUtils.ts" />
/// <reference path="../utils/RectangleUtils.ts" />
/// <reference path="../_definitions.ts" />
/**
* Phaser - Components - InputHandler
@ -27,7 +25,7 @@ module Phaser.Components {
/**
* Reference to Phaser.Game
*/
public game: Game;
public game: Phaser.Game;
/**
* Local private reference to its parent game object.
@ -551,7 +549,7 @@ module Phaser.Components {
* @param boundsRect If you want to restrict the drag of this sprite to a specific FlxRect, pass the FlxRect here, otherwise it's free to drag anywhere
* @param boundsSprite If you want to restrict the drag of this sprite to within the bounding box of another sprite, pass it here
*/
public enableDrag(lockCenter: boolean = false, bringToTop: boolean = false, pixelPerfect: boolean = false, alphaThreshold: number = 255, boundsRect: Rectangle = null, boundsSprite: Phaser.Sprite = null): void {
public enableDrag(lockCenter: boolean = false, bringToTop: boolean = false, pixelPerfect: boolean = false, alphaThreshold: number = 255, boundsRect: Rectangle = null, boundsSprite: Phaser.Sprite = null) {
this._dragPoint = new Point;
this.draggable = true;
@ -576,7 +574,7 @@ module Phaser.Components {
/**
* Stops this sprite from being able to be dragged. If it is currently the target of an active drag it will be stopped immediately. Also disables any set callbacks.
*/
public disableDrag(): void {
public disableDrag() {
if (this._pointerData)
{
@ -595,7 +593,7 @@ module Phaser.Components {
/**
* Called by Pointer when drag starts on this Sprite. Should not usually be called directly.
*/
public startDrag(pointer: Pointer): void {
public startDrag(pointer: Pointer) {
this.isDragged = true;
this._draggedPointerID = pointer.id;
@ -625,7 +623,7 @@ module Phaser.Components {
/**
* Called by Pointer when drag is stopped on this Sprite. Should not usually be called directly.
*/
public stopDrag(pointer: Pointer): void {
public stopDrag(pointer: Pointer) {
this.isDragged = false;
this._draggedPointerID = -1;
@ -648,7 +646,7 @@ module Phaser.Components {
* @param allowHorizontal To enable the sprite to be dragged horizontally set to true, otherwise false
* @param allowVertical To enable the sprite to be dragged vertically set to true, otherwise false
*/
public setDragLock(allowHorizontal: boolean = true, allowVertical: boolean = true): void {
public setDragLock(allowHorizontal: boolean = true, allowVertical: boolean = true) {
this.allowHorizontalDrag = allowHorizontal;
this.allowVerticalDrag = allowVertical;
}
@ -662,7 +660,7 @@ module Phaser.Components {
* @param onDrag If true the sprite will snap to the grid while being dragged
* @param onRelease If true the sprite will snap to the grid when released
*/
public enableSnap(snapX: number, snapY: number, onDrag: boolean = true, onRelease: boolean = false): void {
public enableSnap(snapX: number, snapY: number, onDrag: boolean = true, onRelease: boolean = false) {
this.snapOnDrag = onDrag;
this.snapOnRelease = onRelease;
this.snapX = snapX;
@ -672,7 +670,7 @@ module Phaser.Components {
/**
* Stops the sprite from snapping to a grid during drag or release.
*/
public disableSnap(): void {
public disableSnap() {
this.snapOnDrag = false;
this.snapOnRelease = false;
}
@ -680,7 +678,7 @@ module Phaser.Components {
/**
* Bounds Rect check for the sprite drag
*/
private checkBoundsRect(): void {
private checkBoundsRect() {
if (this._parent.x < this.boundsRect.left)
{
this._parent.x = this.boundsRect.x;
@ -703,7 +701,7 @@ module Phaser.Components {
/**
* Parent Sprite Bounds check for the sprite drag
*/
private checkBoundsSprite(): void {
private checkBoundsSprite() {
if (this._parent.x < this.boundsSprite.x)
{
this._parent.x = this.boundsSprite.x;

View file

@ -1,13 +1,4 @@
/// <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" />
/// <reference path="../_definitions.ts" />
/**
* Phaser - InputManager
@ -32,7 +23,7 @@ module Phaser {
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.gestures = new Gestures(this.game);
this.onDown = new Phaser.Signal();
this.onUp = new Phaser.Signal();
@ -58,7 +49,7 @@ module Phaser {
/**
* Local reference to game.
*/
public game: Game;
public game: Phaser.Game;
/**
* How often should the input pointers be checked for updates?
@ -171,7 +162,7 @@ module Phaser {
* Phaser.Gestures handler
* @type {Gestures}
*/
public gestures: Gestures;
//public gestures: Gestures;
/**
* A vector object representing the current position of the Pointer.
@ -458,7 +449,7 @@ module Phaser {
this.keyboard.start();
this.touch.start();
this.mspointer.start();
this.gestures.start();
//this.gestures.start();
this.mousePointer.active = true;

View file

@ -1,4 +1,4 @@
/// <reference path="../Game.ts" />
/// <reference path="../_definitions.ts" />
/**
* Phaser - Keyboard
@ -23,7 +23,7 @@ module Phaser {
* @property game
* @type {Phaser.Game}
**/
public game: Game;
public game: Phaser.Game;
private _keys = {};
private _capture = {};
@ -211,6 +211,7 @@ module Phaser {
}
/*
// Letters
public static A: number = "A".charCodeAt(0);
public static B: number = "B".charCodeAt(0);
@ -320,7 +321,7 @@ module Phaser {
public static DELETE: number = 46;
public static HELP: number = 47;
public static NUM_LOCK: number = 144;
*/
}
}

View file

@ -1,5 +1,4 @@
/// <reference path="../Game.ts" />
/// <reference path="Pointer.ts" />
/// <reference path="../_definitions.ts" />
/**
* Phaser - MSPointer
@ -29,7 +28,7 @@ module Phaser {
* @property game
* @type Game
**/
public game: Game;
public game: Phaser.Game;
/**
* You can disable all Input by setting disabled = true. While set all new input related events will be ignored.

View file

@ -1,4 +1,4 @@
/// <reference path="../Game.ts" />
/// <reference path="../_definitions.ts" />
/**
* Phaser - Mouse
@ -22,7 +22,7 @@ module Phaser {
* @property game
* @type {Phaser.Game}
**/
public game: Game;
public game: Phaser.Game;
public static LEFT_BUTTON: number = 0;
public static MIDDLE_BUTTON: number = 1;

View file

@ -1,5 +1,4 @@
/// <reference path="../Game.ts" />
/// <reference path="../math/Vec2.ts" />
/// <reference path="../_definitions.ts" />
/**
* Phaser - Pointer
@ -43,7 +42,7 @@ module Phaser {
* @type {Phaser.Game}
* @private
**/
public game: Game;
public game: Phaser.Game;
/**
* Local private variable to store the status of dispatching a hold event

View file

@ -1,5 +1,4 @@
/// <reference path="../Game.ts" />
/// <reference path="Pointer.ts" />
/// <reference path="../_definitions.ts" />
/**
* Phaser - Touch
@ -32,7 +31,7 @@ module Phaser {
* @property game
* @type {Phaser.Game}
**/
public game: Game;
public game: Phaser.Game;
/**
* You can disable all Input by setting disabled = true. While set all new input related events will be ignored.

View file

@ -1,4 +1,4 @@
/// <reference path="../Game.ts" />
/// <reference path="../_definitions.ts" />
/**
* Phaser - AnimationLoader

View file

@ -1,4 +1,4 @@
/// <reference path="../Game.ts" />
/// <reference path="../_definitions.ts" />
/**
* Phaser - Cache
@ -28,7 +28,7 @@ module Phaser {
/**
* Local reference to Game.
*/
public game: Game;
public game: Phaser.Game;
/**
* Canvas key-value container.

View file

@ -1,4 +1,4 @@
/// <reference path="../Game.ts" />
/// <reference path="../_definitions.ts" />
/**
* Phaser - Loader
@ -36,7 +36,7 @@ module Phaser {
/**
* Local reference to Game.
*/
public game: Game;
public game: Phaser.Game;
/**
* Array stores assets keys. So you can get that asset by its unique key.

View file

@ -1,4 +1,4 @@
/// <reference path="../Game.ts" />
/// <reference path="../_definitions.ts" />
/**
* Phaser - GameMath
@ -25,7 +25,7 @@ module Phaser {
}
}
public game: Game;
public game: Phaser.Game;
// Pre-calculated tables containing Math.sin(angle) and Math.cos(angle) from -180 to 180
// So sinA[sprite.rotation] would be the same as Math.sin(sprite.rotation) without a call to Math.sin

View file

@ -1,4 +1,4 @@
/// <reference path="../gameobjects/IGameObject.ts" />
/// <reference path="../_definitions.ts" />
/**
* Phaser - LinkedList
@ -23,7 +23,8 @@ module Phaser {
/**
* Stores a reference to an <code>IGameObject</code>.
*/
public object: IGameObject;
//public object: IGameObject;
public object;
/**
* Stores a reference to the next link in the list.

View file

@ -1,4 +1,4 @@
/// <reference path="../Game.ts" />
/// <reference path="../_definitions.ts" />
/**
* Phaser - Mat3

View file

@ -1,6 +1,4 @@
/// <reference path="../Game.ts" />
/// <reference path="../math/Vec2.ts" />
/// <reference path="../math/Mat3.ts" />
/// <reference path="../_definitions.ts" />
/**
* Phaser - Mat3Utils

View file

@ -1,6 +1,4 @@
/// <reference path="../Game.ts" />
/// <reference path="../geom/Rectangle.ts" />
/// <reference path="LinkedList.ts" />
/// <reference path="../_definitions.ts" />
/**
* Phaser - QuadTree
@ -23,7 +21,8 @@ module Phaser {
* @param {Number} height Desired height of this node.
* @param {Number} parent The parent branch or node. Pass null to create a root.
*/
constructor(manager: Phaser.Physics.Manager, x: number, y: number, width: number, height: number, parent: QuadTree = null) {
//constructor(manager: Phaser.Physics.Manager, x: number, y: number, width: number, height: number, parent: QuadTree = null) {
constructor(manager, x: number, y: number, width: number, height: number, parent: QuadTree = null) {
super(x, y, width, height);
@ -104,7 +103,8 @@ module Phaser {
private _overlapProcessed: boolean;
private _checkObject;
public static physics: Phaser.Physics.Manager;
//public static physics: Phaser.Physics.Manager;
public static physics;
/**
* Flag for specifying that you want to add an object to the A list.

View file

@ -0,0 +1,19 @@
var Shapes;
(function (Shapes) {
var Point = Shapes.Point = (function () {
function Point(x, y) {
this.x = x;
this.y = y;
}
Point.prototype.getDist = function () {
return Math.sqrt((this.x * this.x) + (this.y * this.y));
};
Point.origin = new Point(0, 0);
return Point;
})();
})(Shapes || (Shapes = {}));
var p = new Shapes.Point(3, 4);
var dist = p.getDist();

View file

@ -1,4 +1,4 @@
/// <reference path="../Game.ts" />
/// <reference path="../_definitions.ts" />
/**
* Phaser - RandomDataGenerator
@ -17,7 +17,7 @@ module Phaser {
* @param {Array} seeds
* @return {Phaser.RandomDataGenerator}
*/
constructor(seeds: string[] = []) {
constructor(seeds: string[]= []) {
this.sow(seeds);
@ -55,7 +55,7 @@ module Phaser {
* @method uint32
* @private
*/
private uint32() {
private uint32(): number {
return this.rnd.apply(this) * 0x100000000; // 2^32
@ -65,7 +65,7 @@ module Phaser {
* @method fract32
* @private
*/
private fract32() {
private fract32(): number {
return this.rnd.apply(this) + (this.rnd.apply(this) * 0x200000 | 0) * 1.1102230246251565e-16; // 2^-53
@ -76,7 +76,7 @@ module Phaser {
* @method rnd
* @private
*/
private rnd() {
private rnd(): number {
var t = 2091639 * this.s0 + this.c * 2.3283064365386963e-10; // 2^-32
@ -122,7 +122,7 @@ module Phaser {
* @method sow
* @param {Array} seeds
*/
public sow(seeds: string[] = []) {
public sow(seeds: string[]= []) {
this.s0 = this.hash(' ');
this.s1 = this.hash(this.s0);
@ -230,7 +230,7 @@ module Phaser {
b = a = '';
a++ < 36;
b += ~a % 5 | a * 3 & 4 ? (a ^ 15 ? 8 ^ this.frac * (a ^ 20 ? 16 : 4) : 4).toString(16) : '-'
);
);
return b;
}

View file

@ -1,4 +1,4 @@
/// <reference path="../Game.ts" />
/// <reference path="../_definitions.ts" />
/**
* Phaser - Vec2
@ -47,7 +47,7 @@ module Phaser {
* @param {any} source - The object to copy from.
* @return {Vec2} This Vec2 object.
**/
public copyFrom(source: any): Vec2 {
public copyFrom(source: any): Phaser.Vec2 {
return this.setTo(source.x, source.y);
}
@ -57,7 +57,7 @@ module Phaser {
* @param {Number} y The y position of the vector
* @return {Vec2} This object
**/
public setTo(x: number, y: number): Vec2 {
public setTo(x: number, y: number): Phaser.Vec2 {
this.x = x;
this.y = y;
@ -71,7 +71,7 @@ module Phaser {
* @param {Vec2} other The other Vector.
* @return {Vec2} This for chaining.
*/
public add(a: Vec2): Vec2 {
public add(a: Phaser.Vec2): Phaser.Vec2 {
this.x += a.x;
this.y += a.y;
@ -85,7 +85,7 @@ module Phaser {
* @param {Vec2} other The other Vector.
* @return {Vec2} This for chaining.
*/
public subtract(v: Vec2): Vec2 {
public subtract(v: Phaser.Vec2): Phaser.Vec2 {
this.x -= v.x;
this.y -= v.y;
@ -99,7 +99,7 @@ module Phaser {
* @param {Vec2} other The other Vector.
* @return {Vec2} This for chaining.
*/
public multiply(v: Vec2): Vec2 {
public multiply(v: Phaser.Vec2): Phaser.Vec2 {
this.x *= v.x;
this.y *= v.y;
@ -113,7 +113,7 @@ module Phaser {
* @param {Vec2} other The other Vector.
* @return {Vec2} This for chaining.
*/
public divide(v: Vec2): Vec2 {
public divide(v: Phaser.Vec2): Phaser.Vec2 {
this.x /= v.x;
this.y /= v.y;
@ -144,7 +144,7 @@ module Phaser {
*
* @return {Vec2} This for chaining.
*/
public normalize(): Vec2 {
public normalize(): Phaser.Vec2 {
var inv = (this.x != 0 || this.y != 0) ? 1 / Math.sqrt(this.x * this.x + this.y * this.y) : 0;
this.x *= inv;
@ -159,7 +159,7 @@ module Phaser {
* @param {Vec2} a Reference to a source Vec2 object.
* @return {Number}
*/
public dot(a: Vec2): number {
public dot(a: Phaser.Vec2): number {
return ((this.x * a.x) + (this.y * a.y));
}
@ -169,7 +169,7 @@ module Phaser {
* @param {Vec2} a Reference to a source Vec2 object.
* @return {Number}
*/
public cross(a: Vec2): number {
public cross(a: Phaser.Vec2): number {
return ((this.x * a.y) - (this.y * a.x));
}
@ -179,7 +179,7 @@ module Phaser {
* @param {Vec2} a Reference to a source Vec2 object.
* @return {Number}
*/
public projectionLength(a: Vec2): number {
public projectionLength(a: Phaser.Vec2): number {
var den: number = a.dot(a);
@ -200,7 +200,7 @@ module Phaser {
* @param {Vec2} a Reference to a source Vec2 object.
* @return {Number}
*/
public angle(a: Vec2): number {
public angle(a: Phaser.Vec2): number {
return Math.atan2(a.x * this.y - a.y * this.x, a.x * this.x + a.y * this.y);
}
@ -211,7 +211,7 @@ module Phaser {
* @param {?number=} y The scaling factor in the y direction. If this is not specified, the x scaling factor will be used.
* @return {Vec2} This for chaining.
*/
public scale(x: number, y:number): Vec2 {
public scale(x: number, y: number): Phaser.Vec2 {
this.x *= x;
this.y *= y || x;
@ -225,7 +225,7 @@ module Phaser {
* @param {number} scalar
* @return {Vec2} This for chaining.
*/
public multiplyByScalar(scalar: number): Vec2 {
public multiplyByScalar(scalar: number): Phaser.Vec2 {
this.x *= scalar;
this.y *= scalar;
@ -240,7 +240,7 @@ module Phaser {
* @param {number} scalar
* @return {Vec2} This for chaining.
*/
public multiplyAddByScalar(a: Vec2, scalar: number): Vec2 {
public multiplyAddByScalar(a: Phaser.Vec2, scalar: number): Phaser.Vec2 {
this.x += a.x * scalar;
this.y += a.y * scalar;
@ -254,7 +254,7 @@ module Phaser {
* @param {number} scalar
* @return {Vec2} This for chaining.
*/
public divideByScalar(scalar: number): Vec2 {
public divideByScalar(scalar: number): Phaser.Vec2 {
this.x /= scalar;
this.y /= scalar;
@ -267,7 +267,7 @@ module Phaser {
*
* @return {Vec2} This for chaining.
*/
public reverse(): Vec2 {
public reverse(): Phaser.Vec2 {
this.x = -this.x;
this.y = -this.y;
@ -290,8 +290,7 @@ module Phaser {
* @return {string} a string representation of the object.
**/
public toString(): string {
//return "[{Vec2 (x=" + this.x + " y=" + this.y + ")}]";
return "x=" + this.x + " y=" + this.y;
return "[{Vec2 (x=" + this.x + " y=" + this.y + ")}]";
}
}

View file

@ -1,5 +1,4 @@
/// <reference path="../Game.ts" />
/// <reference path="Vec2.ts" />
/// <reference path="../_definitions.ts" />
/**
* Phaser - Vec2Utils

View file

@ -1,4 +1,4 @@
/// <reference path="../Game.ts" />
/// <reference path="../_definitions.ts" />
/**
* Phaser - Net
@ -13,7 +13,7 @@ module Phaser {
/**
* Net constructor
*/
constructor(game: Game) {
constructor(game: Phaser.Game) {
this.game = game;
@ -22,7 +22,7 @@ module Phaser {
/**
* Local reference to the current Phaser.Game.
*/
public game: Game;
public game: Phaser.Game;
/**
* Compares the given domain name against the hostname of the browser containing the game.

View file

@ -1,465 +0,0 @@
/// <reference path="../Game.ts" />
/// <reference path="../core/Group.ts" />
/// <reference path="ArcadeParticle.ts" />
/// <reference path="../utils/SpriteUtils.ts" />
/**
* 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
* at set intervals, and fixes their positions and velocities accorindgly.
*/
module Phaser {
export class ArcadeEmitter extends Group {
/**
* Creates a new <code>Emitter</code> object at a specific position.
* Does NOT automatically generate or attach particles!
*
* @param x {number} The X position of the emitter.
* @param y {number} The Y position of the emitter.
* @param [size] {number} Specifies a maximum capacity for this emitter.
*/
constructor(game: Game, x: number = 0, y: number = 0, size: number = 0) {
super(game, size);
this.x = x;
this.y = y;
this.width = 0;
this.height = 0;
this.minParticleSpeed = new Vec2(-100, -100);
this.maxParticleSpeed = new Vec2(100, 100);
this.minRotation = -360;
this.maxRotation = 360;
this.gravity = 0;
this.particleClass = null;
this.particleDrag = new Vec2();
this.frequency = 0.1;
this.lifespan = 3;
this.bounce = 0;
this._quantity = 0;
this._counter = 0;
this._explode = true;
this.on = false;
this.exists = true;
this.active = true;
this.visible = true;
}
/**
* The X position of the top left corner of the emitter in world space.
*/
public x: number;
/**
* The Y position of the top left corner of emitter in world space.
*/
public y: number;
/**
* The width of the emitter. Particles can be randomly generated from anywhere within this box.
*/
public width: number;
/**
* The height of the emitter. Particles can be randomly generated from anywhere within this box.
*/
public height: number;
/**
*
*/
public alive: boolean;
/**
*
*/
public active: boolean;
/**
* The minimum possible velocity of a particle.
* The default value is (-100,-100).
*/
public minParticleSpeed: Vec2;
/**
* The maximum possible velocity of a particle.
* The default value is (100,100).
*/
public maxParticleSpeed: Vec2;
/**
* The X and Y drag component of particles launched from the emitter.
*/
public particleDrag: Vec2;
/**
* The minimum possible angular velocity of a particle. The default value is -360.
* NOTE: rotating particles are more expensive to draw than non-rotating ones!
*/
public minRotation: number;
/**
* The maximum possible angular velocity of a particle. The default value is 360.
* NOTE: rotating particles are more expensive to draw than non-rotating ones!
*/
public maxRotation: number;
/**
* Sets the <code>acceleration.y</code> member of each particle to this value on launch.
*/
public gravity: number;
/**
* Determines whether the emitter is currently emitting particles.
* It is totally safe to directly toggle this.
*/
public on: boolean;
/**
* How often a particle is emitted (if emitter is started with Explode == false).
*/
public frequency: number;
/**
* How long each particle lives once it is emitted.
* Set lifespan to 'zero' for particles to live forever.
*/
public lifespan: number;
/**
* How much each particle should bounce. 1 = full bounce, 0 = no bounce.
*/
public bounce: number;
/**
* Set your own particle class type here.
* Default is <code>Particle</code>.
*/
public particleClass;
/**
* Internal helper for deciding how many particles to launch.
*/
private _quantity: number;
/**
* Internal helper for the style of particle emission (all at once, or one at a time).
*/
private _explode: boolean;
/**
* Internal helper for deciding when to launch particles or kill them.
*/
private _timer: number;
/**
* Internal counter for figuring out how many particles to launch.
*/
private _counter: number;
/**
* Internal point object, handy for reusing for memory mgmt purposes.
*/
private _point: Vec2;
/**
* Clean up memory.
*/
public destroy() {
this.minParticleSpeed = null;
this.maxParticleSpeed = null;
this.particleDrag = null;
this.particleClass = null;
this._point = null;
super.destroy();
}
/**
* This function generates a new array of particle sprites to attach to the emitter.
*
* @param graphics If you opted to not pre-configure an array of Sprite objects, you can simply pass in a particle image or sprite sheet.
* @param quantity {number} The number of particles to generate when using the "create from image" option.
* @param multiple {boolean} Whether the image in the Graphics param is a single particle or a bunch of particles (if it's a bunch, they need to be square!).
* @param collide {number} Whether the particles should be flagged as not 'dead' (non-colliding particles are higher performance). 0 means no collisions, 0-1 controls scale of particle's bounding box.
*
* @return This Emitter instance (nice for chaining stuff together, if you're into that).
*/
public makeParticles(graphics, quantity: number = 50, multiple: boolean = false, collide: number = 0): ArcadeEmitter {
this.maxSize = quantity;
var totalFrames: number = 1;
/*
if(Multiple)
{
var sprite:Sprite = new Sprite(this.game);
sprite.loadGraphic(Graphics,true);
totalFrames = sprite.frames;
sprite.destroy();
}
*/
var randomFrame: number;
var particle: ArcadeParticle;
var i: number = 0;
while (i < quantity)
{
if (this.particleClass == null)
{
particle = new ArcadeParticle(this.game);
}
else
{
particle = new this.particleClass(this.game);
}
if (multiple)
{
/*
randomFrame = this.game.math.random()*totalFrames;
*/
}
else
{
if (graphics)
{
particle.texture.loadImage(graphics);
}
}
if (collide > 0)
{
//particle.body.allowCollisions = Types.ANY;
particle.body.type = Types.BODY_DYNAMIC;
particle.width *= collide;
particle.height *= collide;
}
else
{
//particle.body.allowCollisions = Types.NONE;
}
particle.exists = false;
// Center the origin for rotation assistance
//particle.transform.origin.setTo(particle.body.bounds.halfWidth, particle.body.bounds.halfHeight);
this.add(particle);
i++;
}
return this;
}
public preUpdate() { }
public postUpdate() { }
/**
* Called automatically by the game loop, decides when to launch particles and when to "die".
*/
public update() {
if (this.on)
{
if (this._explode)
{
this.on = false;
var i: number = 0;
var l: number = this._quantity;
if ((l <= 0) || (l > this.length))
{
l = this.length;
}
while (i < l)
{
this.emitParticle();
i++;
}
this._quantity = 0;
}
else
{
this._timer += this.game.time.elapsed;
while ((this.frequency > 0) && (this._timer > this.frequency) && this.on)
{
this._timer -= this.frequency;
this.emitParticle();
if ((this._quantity > 0) && (++this._counter >= this._quantity))
{
this.on = false;
this._quantity = 0;
}
}
}
}
super.update();
}
/**
* Call this function to turn off all the particles and the emitter.
*/
public kill() {
this.on = false;
this.alive = false;
this.exists = false;
}
/**
* Handy for bringing game objects "back to life". Just sets alive and exists back to true.
* In practice, this is most often called by <code>Object.reset()</code>.
*/
public revive() {
this.alive = true;
this.exists = true;
}
/**
* Call this function to start emitting particles.
*
* @param explode {boolean} Whether the particles should all burst out at once.
* @param lifespan {number} How long each particle lives once emitted. 0 = forever.
* @param frequency {number} Ignored if Explode is set to true. Frequency is how often to emit a particle. 0 = never emit, 0.1 = 1 particle every 0.1 seconds, 5 = 1 particle every 5 seconds.
* @param quantity {number} How many particles to launch. 0 = "all of the particles".
*/
public start(explode: boolean = true, lifespan: number = 0, frequency: number = 0.1, quantity: number = 0) {
this.revive();
this.visible = true;
this.on = true;
this._explode = explode;
this.lifespan = lifespan;
this.frequency = frequency;
this._quantity += quantity;
this._counter = 0;
this._timer = 0;
}
/**
* This function can be used both internally and externally to emit the next particle.
*/
public emitParticle() {
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.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.rnd.integer * (this.maxParticleSpeed.x - this.minParticleSpeed.x);
}
else
{
particle.body.velocity.x = this.minParticleSpeed.x;
}
if (this.minParticleSpeed.y != this.maxParticleSpeed.y)
{
particle.body.velocity.y = this.minParticleSpeed.y + this.game.rnd.integer * (this.maxParticleSpeed.y - this.minParticleSpeed.y);
}
else
{
particle.body.velocity.y = this.minParticleSpeed.y;
}
//particle.body.acceleration.y = this.gravity;
if (this.minRotation != this.maxRotation && this.minRotation !== 0 && this.maxRotation !== 0)
{
particle.body.angularVelocity = this.minRotation + this.game.rnd.integer * (this.maxRotation - this.minRotation);
}
else
{
particle.body.angularVelocity = this.minRotation;
}
if (particle.body.angularVelocity != 0)
{
particle.rotation = this.game.rnd.integer * 360 - 180;
}
//particle.body.drag.x = this.particleDrag.x;
//particle.body.drag.y = this.particleDrag.y;
particle.onEmit();
}
/**
* A more compact way of setting the width and height of the emitter.
*
* @param width {number} The desired width of the emitter (particles are spawned randomly within these dimensions).
* @param height {number} The desired height of the emitter.
*/
public setSize(width: number, height: number) {
this.width = width;
this.height = height;
}
/**
* A more compact way of setting the X velocity range of the emitter.
*
* @param Min {number} The minimum value for this range.
* @param Max {number} The maximum value for this range.
*/
public setXSpeed(min: number = 0, max: number = 0) {
this.minParticleSpeed.x = min;
this.maxParticleSpeed.x = max;
}
/**
* A more compact way of setting the Y velocity range of the emitter.
*
* @param Min {number} The minimum value for this range.
* @param Max {number} The maximum value for this range.
*/
public setYSpeed(min: number = 0, max: number = 0) {
this.minParticleSpeed.y = min;
this.maxParticleSpeed.y = max;
}
/**
* A more compact way of setting the angular velocity constraints of the emitter.
*
* @param Min {number} The minimum value for this range.
* @param Max {number} The maximum value for this range.
*/
public setRotation(min: number = 0, max: number = 0) {
this.minRotation = min;
this.maxRotation = max;
}
/**
* Change the emitter's midpoint to match the midpoint of a <code>Object</code>.
*
* @param Object {object} The <code>Object</code> that you want to sync up with.
*/
public at(object: Sprite) {
//this.x = object.body.bounds.halfWidth - (this.width >> 1);
//this.y = object.body.bounds.halfHeight - (this.height >> 1);
}
}
}

View file

@ -1,64 +0,0 @@
/// <reference path="../Game.ts" />
/// <reference path="../gameobjects/Sprite.ts" />
/**
* 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.
*/
module Phaser {
export class ArcadeParticle extends Sprite {
/**
* Instantiate a new particle. Like <code>Sprite</code>, all meaningful creation
* happens during <code>loadGraphic()</code> or <code>makeGraphic()</code> or whatever.
*/
constructor(game: Game) {
super(game);
this.body.type = Types.BODY_DYNAMIC;
this.lifespan = 0;
}
/**
* How long this particle lives before it disappears.
* NOTE: this is a maximum, not a minimum; the object
* could get recycled before its lifespan is up.
*/
public lifespan: number;
/**
* The particle's main update logic. Basically it checks to see if it should be dead yet.
*/
public update() {
// Lifespan behavior
if (this.lifespan <= 0)
{
return;
}
this.lifespan -= this.game.time.elapsed;
if (this.lifespan <= 0)
{
this.kill();
}
}
/**
* Triggered whenever this object is launched by a <code>Emitter</code>.
* You can override this to add custom behavior like a sound or AI or something.
*/
public onEmit() {
}
}
}

View file

@ -1,23 +0,0 @@
/**
* Phaser
* www.phaser.io
*
* v1.0.0 - August 12th 2013
*
* A feature-packed 2D canvas game framework born from the firey pits of Flixel and Kiwi.
*
* Richard Davey (@photonstorm)
*
* Many thanks to Adam Saltsman (@ADAMATOMIC) for releasing Flixel, from both which Phaser
* and my love of game development took a lot of inspiration.
*
* "If you want your children to be intelligent, read them fairy tales."
* "If you want them to be more intelligent, read them more fairy tales."
* -- Albert Einstein
*/
var Phaser;
(function (Phaser) {
Phaser.VERSION = 'Phaser version 1.0.0';
Phaser.GAMES = [];
})(Phaser || (Phaser = {}));

View file

@ -1,49 +0,0 @@
/// <reference path="../Game.ts" />
/**
* Phaser - Physics Manager
*
* Eventually this will handle switching between the default ArcadePhysics manager or the new AdvancedPhysics manager.
* For now we direct everything through ArcadePhysics.
*/
module Phaser.Physics {
export class Manager {
constructor(game: Game) {
this.game = game;
this.arcade = new Phaser.Physics.ArcadePhysics(this.game, this.game.stage.width, this.game.stage.height);
this.gravity = this.arcade.gravity;
this.bounds = this.arcade.bounds;
}
/**
* Local reference to Game.
*/
public game: Game;
/**
* Instance of the ArcadePhysics manager.
*/
public arcade: Phaser.Physics.ArcadePhysics;
public gravity: Vec2;
public bounds: Rectangle;
/**
* Called by the main Game.loop
*/
public update() {
//this.arcade.updateMotion
}
}
}

View file

@ -1,15 +0,0 @@
I've been extremely busy working on a proper advanced physics system for Phaser.
It has all the sorts of things you'd expect from a real 2D physics engine and will allow for a whole new range of cool games to be made.
However I'm not 100% happy with the implementation right yet, there are still too many rough edges and places where performance can be
improved. It also adds quite a bit of extra file size to the library, so I'm not bundling it with the 1.0 release. It will be released
as a stand-alone extension to Phaser in due course.
It has been a lot of hard work to create, taking many weeks of development time and money, so be warned I may decide to charge for it.
Or I may just give it away for free, I've not yet decided - but for now I reserve that right at least.
Cheers,
Richard Davey
1st August 2013

File diff suppressed because it is too large Load diff

View file

@ -1,7 +1,4 @@
/// <reference path="../../math/Vec2.ts" />
/// <reference path="../../geom/Point.ts" />
/// <reference path="../../math/Vec2Utils.ts" />
/// <reference path="ArcadePhysics.ts" />
/// <reference path="../../_definitions.ts" />
/**
* Phaser - ArcadePhysics - Body
@ -19,7 +16,7 @@ module Phaser.Physics {
// Fixture properties
// Will extend into its own class at a later date - can move the fixture defs there and add shape support, but this will do for 1.0 release
this.bounds = new Rectangle;
this.bounds = new Phaser.Rectangle;
this._width = sprite.width;
this._height = sprite.height;
@ -29,29 +26,29 @@ module Phaser.Physics {
//this.gravity = Vec2Utils.clone(ArcadePhysics.gravity);
//this.bounce = Vec2Utils.clone(ArcadePhysics.bounce);
this.velocity = new Vec2;
this.acceleration = new Vec2;
this.velocity = new Phaser.Vec2;
this.acceleration = new Phaser.Vec2;
//this.drag = Vec2Utils.clone(ArcadePhysics.drag);
this.maxVelocity = new Vec2(10000, 10000);
this.maxVelocity = new Phaser.Vec2(10000, 10000);
this.angularVelocity = 0;
this.angularAcceleration = 0;
this.angularDrag = 0;
this.touching = Types.NONE;
this.wasTouching = Types.NONE;
this.allowCollisions = Types.ANY;
this.touching = Phaser.Types.NONE;
this.wasTouching = Phaser.Types.NONE;
this.allowCollisions = Phaser.Types.ANY;
this.position = new Vec2(sprite.x + this.bounds.halfWidth, sprite.y + this.bounds.halfHeight);
this.oldPosition = new Vec2(sprite.x + this.bounds.halfWidth, sprite.y + this.bounds.halfHeight);
this.offset = new Vec2;
this.position = new Phaser.Vec2(sprite.x + this.bounds.halfWidth, sprite.y + this.bounds.halfHeight);
this.oldPosition = new Phaser.Vec2(sprite.x + this.bounds.halfWidth, sprite.y + this.bounds.halfHeight);
this.offset = new Phaser.Vec2;
}
/**
* Reference to Phaser.Game
*/
public game: Game;
public game: Phaser.Game;
/**
* Reference to the parent Sprite
@ -68,13 +65,13 @@ module Phaser.Physics {
*/
public type: number;
public gravity: Vec2;
public bounce: Vec2;
public gravity: Phaser.Vec2;
public bounce: Phaser.Vec2;
public velocity: Vec2;
public acceleration: Vec2;
public drag: Vec2;
public maxVelocity: Vec2;
public velocity: Phaser.Vec2;
public acceleration: Phaser.Vec2;
public drag: Phaser.Vec2;
public maxVelocity: Phaser.Vec2;
public angularVelocity: number = 0;
public angularAcceleration: number = 0;
@ -92,12 +89,10 @@ module Phaser.Physics {
public wasTouching: number;
public mass: number = 1;
public position: Vec2;
public oldPosition: Vec2;
public offset: Vec2;
public bounds: Rectangle;
public position: Phaser.Vec2;
public oldPosition: Phaser.Vec2;
public offset: Phaser.Vec2;
public bounds: Phaser.Rectangle;
private _width: number = 0;
private _height: number = 0;

View file

@ -1,363 +0,0 @@
/// <reference path="../../Game.ts" />
/// <reference path="../../gameobjects/Sprite.ts" />
/**
* Phaser - Motion
*
* The Motion class contains lots of useful functions for moving game objects around in world space.
*/
module Phaser {
export class Motion {
constructor(game: Game) {
this.game = game;
}
public game: Game;
/**
* Given the angle and speed calculate the velocity and return it as a Point
*
* @param {number} angle The angle (in degrees) calculated in clockwise positive direction (down = 90 degrees positive, right = 0 degrees positive, up = 90 degrees negative)
* @param {number} speed The speed it will move, in pixels per second sq
*
* @return {Point} A Point where Point.x contains the velocity x value and Point.y contains the velocity y value
*/
public velocityFromAngle(angle: number, speed: number): Point {
if (isNaN(speed))
{
speed = 0;
}
var a: number = this.game.math.degreesToRadians(angle);
return new Point((Math.cos(a) * speed), (Math.sin(a) * speed));
}
/**
* Sets the source Sprite x/y velocity so it will move directly towards the destination Sprite at the speed given (in pixels per second)<br>
* If you specify a maxTime then it will adjust the speed (over-writing what you set) so it arrives at the destination in that number of seconds.<br>
* Timings are approximate due to the way Flash timers work, and irrespective of SWF frame rate. Allow for a variance of +- 50ms.<br>
* The source object doesn't stop moving automatically should it ever reach the destination coordinates.<br>
* If you need the object to accelerate, see accelerateTowardsObject() instead
* Note: Doesn't take into account acceleration, maxVelocity or drag (if you set drag or acceleration too high this object may not move at all)
*
* @param {Sprite} source The Sprite on which the velocity will be set
* @param {Sprite} dest The Sprite where the source object will move to
* @param {number} speed The speed it will move, in pixels per second (default is 60 pixels/sec)
* @param {number} maxTime Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the source will arrive at destination in the given number of ms
*/
public moveTowardsObject(source: Sprite, dest: Sprite, speed: number = 60, maxTime: number = 0) {
var a: number = this.angleBetween(source, dest);
if (maxTime > 0)
{
var d: number = this.distanceBetween(source, dest);
// We know how many pixels we need to move, but how fast?
speed = d / (maxTime / 1000);
}
source.body.velocity.x = Math.cos(a) * speed;
source.body.velocity.y = Math.sin(a) * speed;
}
/**
* Sets the x/y acceleration on the source Sprite so it will move towards the destination Sprite at the speed given (in pixels per second)<br>
* You must give a maximum speed value, beyond which the Sprite won't go any faster.<br>
* If you don't need acceleration look at moveTowardsObject() instead.
*
* @param {Sprite} source The Sprite on which the acceleration will be set
* @param {Sprite} dest The Sprite where the source object will move towards
* @param {number} speed The speed it will accelerate in pixels per second
* @param {number} xSpeedMax The maximum speed in pixels per second in which the sprite can move horizontally
* @param {number} ySpeedMax The maximum speed in pixels per second in which the sprite can move vertically
*/
public accelerateTowardsObject(source: Sprite, dest: Sprite, speed: number, xSpeedMax: number, ySpeedMax: number) {
/*
var a: number = this.angleBetween(source, dest);
source.body.velocity.x = 0;
source.body.velocity.y = 0;
source.body.acceleration.x = Math.cos(a) * speed;
source.body.acceleration.y = Math.sin(a) * speed;
source.body.maxVelocity.x = xSpeedMax;
source.body.maxVelocity.y = ySpeedMax;
*/
}
/**
* Move the given Sprite towards the mouse pointer coordinates at a steady velocity
* If you specify a maxTime then it will adjust the speed (over-writing what you set) so it arrives at the destination in that number of seconds.<br>
* Timings are approximate due to the way Flash timers work, and irrespective of SWF frame rate. Allow for a variance of +- 50ms.<br>
* The source object doesn't stop moving automatically should it ever reach the destination coordinates.<br>
*
* @param {Sprite} source The Sprite to move
* @param {number} speed The speed it will move, in pixels per second (default is 60 pixels/sec)
* @param {number} maxTime Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the source will arrive at destination in the given number of ms
*/
public moveTowardsMouse(source: Sprite, speed: number = 60, maxTime: number = 0) {
var a: number = this.angleBetweenMouse(source);
if (maxTime > 0)
{
var d: number = this.distanceToMouse(source);
// We know how many pixels we need to move, but how fast?
speed = d / (maxTime / 1000);
}
source.body.velocity.x = Math.cos(a) * speed;
source.body.velocity.y = Math.sin(a) * speed;
}
/**
* Sets the x/y acceleration on the source Sprite so it will move towards the mouse coordinates at the speed given (in pixels per second)<br>
* You must give a maximum speed value, beyond which the Sprite won't go any faster.<br>
* If you don't need acceleration look at moveTowardsMouse() instead.
*
* @param {Sprite} source The Sprite on which the acceleration will be set
* @param {number} speed The speed it will accelerate in pixels per second
* @param {number} xSpeedMax The maximum speed in pixels per second in which the sprite can move horizontally
* @param {number} ySpeedMax The maximum speed in pixels per second in which the sprite can move vertically
*/
public accelerateTowardsMouse(source: Sprite, speed: number, xSpeedMax: number, ySpeedMax: number) {
/*
var a: number = this.angleBetweenMouse(source);
source.body.velocity.x = 0;
source.body.velocity.y = 0;
source.body.acceleration.x = Math.cos(a) * speed;
source.body.acceleration.y = Math.sin(a) * speed;
source.body.maxVelocity.x = xSpeedMax;
source.body.maxVelocity.y = ySpeedMax;
*/
}
/**
* Sets the x/y velocity on the source Sprite so it will move towards the target coordinates at the speed given (in pixels per second)<br>
* If you specify a maxTime then it will adjust the speed (over-writing what you set) so it arrives at the destination in that number of seconds.<br>
* Timings are approximate due to the way Flash timers work, and irrespective of SWF frame rate. Allow for a variance of +- 50ms.<br>
* The source object doesn't stop moving automatically should it ever reach the destination coordinates.<br>
*
* @param {Sprite} source The Sprite to move
* @param {Point} target The Point coordinates to move the source Sprite towards
* @param {number} speed The speed it will move, in pixels per second (default is 60 pixels/sec)
* @param {number} maxTime Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the source will arrive at destination in the given number of ms
*/
public moveTowardsPoint(source: Sprite, target: Point, speed: number = 60, maxTime: number = 0) {
var a: number = this.angleBetweenPoint(source, target);
if (maxTime > 0)
{
var d: number = this.distanceToPoint(source, target);
// We know how many pixels we need to move, but how fast?
speed = d / (maxTime / 1000);
}
source.body.velocity.x = Math.cos(a) * speed;
source.body.velocity.y = Math.sin(a) * speed;
}
/**
* Sets the x/y acceleration on the source Sprite so it will move towards the target coordinates at the speed given (in pixels per second)<br>
* You must give a maximum speed value, beyond which the Sprite won't go any faster.<br>
* If you don't need acceleration look at moveTowardsPoint() instead.
*
* @param {Sprite} source The Sprite on which the acceleration will be set
* @param {Point} target The Point coordinates to move the source Sprite towards
* @param {number} speed The speed it will accelerate in pixels per second
* @param {number} xSpeedMax The maximum speed in pixels per second in which the sprite can move horizontally
* @param {number} ySpeedMax The maximum speed in pixels per second in which the sprite can move vertically
*/
public accelerateTowardsPoint(source: Sprite, target: Point, speed: number, xSpeedMax: number, ySpeedMax: number) {
/*
var a: number = this.angleBetweenPoint(source, target);
source.body.velocity.x = 0;
source.body.velocity.y = 0;
source.body.acceleration.x = Math.cos(a) * speed;
source.body.acceleration.y = Math.sin(a) * speed;
source.body.maxVelocity.x = xSpeedMax;
source.body.maxVelocity.y = ySpeedMax;
*/
}
/**
* Find the distance between two Sprites, taking their origin into account
*
* @param {Sprite} a The first Sprite
* @param {Sprite} b The second Sprite
* @return {number} int Distance (in pixels)
*/
public distanceBetween(a: Sprite, b: Sprite): number {
return Vec2Utils.distance(a.body.position, b.body.position);
}
/**
* Find the distance from an Sprite to the given Point, taking the source origin into account
*
* @param {Sprite} a The Sprite
* @param {Point} target The Point
* @return {number} Distance (in pixels)
*/
public distanceToPoint(a: Sprite, target: Point): number {
var dx: number = (a.x + a.transform.origin.x) - (target.x);
var dy: number = (a.y + a.transform.origin.y) - (target.y);
return this.game.math.vectorLength(dx, dy);
}
/**
* Find the distance (in pixels, rounded) from the object x/y and the mouse x/y
*
* @param {Sprite} a Sprite to test against
* @return {number} The distance between the given sprite and the mouse coordinates
*/
public distanceToMouse(a: Sprite): number {
var dx: number = (a.x + a.transform.origin.x) - this.game.input.x;
var dy: number = (a.y + a.transform.origin.y) - this.game.input.y;
return this.game.math.vectorLength(dx, dy);
}
/**
* Find the angle (in radians) between an Sprite and an Point. The source sprite takes its x/y and origin into account.
* The angle is calculated in clockwise positive direction (down = 90 degrees positive, right = 0 degrees positive, up = 90 degrees negative)
*
* @param {Sprite} a The Sprite to test from
* @param {Point} target The Point to angle the Sprite towards
* @param {boolean} asDegrees If you need the value in degrees instead of radians, set to true
*
* @return {number} The angle (in radians unless asDegrees is true)
*/
public angleBetweenPoint(a: Sprite, target: Point, asDegrees: boolean = false): number {
var dx: number = (target.x) - (a.x + a.transform.origin.x);
var dy: number = (target.y) - (a.y + a.transform.origin.y);
if (asDegrees)
{
return this.game.math.radiansToDegrees(Math.atan2(dy, dx));
}
else
{
return Math.atan2(dy, dx);
}
}
/**
* Find the angle (in radians) between the two Sprite, taking their x/y and origin into account.
* The angle is calculated in clockwise positive direction (down = 90 degrees positive, right = 0 degrees positive, up = 90 degrees negative)
*
* @param {Sprite} a The Sprite to test from
* @param {Sprite} b The Sprite to test to
* @param {boolean} asDegrees If you need the value in degrees instead of radians, set to true
*
* @return {number} The angle (in radians unless asDegrees is true)
*/
public angleBetween(a: Sprite, b: Sprite, asDegrees: boolean = false): number {
var dx: number = (b.x + b.transform.origin.x) - (a.x + a.transform.origin.x);
var dy: number = (b.y + b.transform.origin.y) - (a.y + a.transform.origin.y);
if (asDegrees)
{
return this.game.math.radiansToDegrees(Math.atan2(dy, dx));
}
else
{
return Math.atan2(dy, dx);
}
}
/**
* Given the Sprite and speed calculate the velocity and return it as an Point based on the direction the sprite is facing
*
* @param {Sprite} parent The Sprite to get the facing value from
* @param {number} speed The speed it will move, in pixels per second sq
*
* @return {Point} An Point where Point.x contains the velocity x value and Point.y contains the velocity y value
*/
public velocityFromFacing(parent: Sprite, speed: number): Point {
/*
var a: number;
if (parent.body.facing == Types.LEFT)
{
a = this.game.math.degreesToRadians(180);
}
else if (parent.body.facing == Types.RIGHT)
{
a = this.game.math.degreesToRadians(0);
}
else if (parent.body.facing == Types.UP)
{
a = this.game.math.degreesToRadians(-90);
}
else if (parent.body.facing == Types.DOWN)
{
a = this.game.math.degreesToRadians(90);
}
return new Point(Math.cos(a) * speed, Math.sin(a) * speed);
*/
return new Point;
}
/**
* Find the angle (in radians) between an Sprite and the mouse, taking their x/y and origin into account.
* The angle is calculated in clockwise positive direction (down = 90 degrees positive, right = 0 degrees positive, up = 90 degrees negative)
*
* @param {Sprite} a The Object to test from
* @param {boolean} asDegrees If you need the value in degrees instead of radians, set to true
*
* @return {number} The angle (in radians unless asDegrees is true)
*/
public angleBetweenMouse(a: Sprite, asDegrees: boolean = false): number {
// In order to get the angle between the object and mouse, we need the objects screen coordinates (rather than world coordinates)
var p: Point = SpriteUtils.getScreenXY(a);
var dx: number = a.game.input.x - p.x;
var dy: number = a.game.input.y - p.y;
if (asDegrees)
{
return this.game.math.radiansToDegrees(Math.atan2(dy, dx));
}
else
{
return Math.atan2(dy, dx);
}
}
}
}

View file

@ -1,6 +1,4 @@
/// <reference path="../Game.ts" />
/// <reference path="../cameras/Camera.ts" />
/// <reference path="IRenderer.ts" />
/// <reference path="../_definitions.ts" />
module Phaser.Renderer.Headless {

View file

@ -1,4 +1,4 @@
/// <reference path="../Game.ts" />
/// <reference path="../_definitions.ts" />
module Phaser {

View file

@ -0,0 +1,19 @@
var Shapes;
(function (Shapes) {
var Point = Shapes.Point = (function () {
function Point(x, y) {
this.x = x;
this.y = y;
}
Point.prototype.getDist = function () {
return Math.sqrt((this.x * this.x) + (this.y * this.y));
};
Point.origin = new Point(0, 0);
return Point;
})();
})(Shapes || (Shapes = {}));
var p = new Shapes.Point(3, 4);
var dist = p.getDist();

View file

@ -1,6 +1,4 @@
/// <reference path="../../Game.ts" />
/// <reference path="../../gameobjects/Sprite.ts" />
/// <reference path="../../cameras/Camera.ts" />
/// <reference path="../../_definitions.ts" />
module Phaser.Renderer.Canvas {
@ -32,7 +30,7 @@ module Phaser.Renderer.Canvas {
private _sin: number = 0;
private _cos: number = 1;
public preRender(camera: Camera): boolean {
public preRender(camera: Phaser.Camera): boolean {
if (camera.visible == false || camera.transform.scale.x == 0 || camera.transform.scale.y == 0 || camera.texture.alpha < 0.1)
{
@ -87,7 +85,7 @@ module Phaser.Renderer.Canvas {
}
public postRender(camera: Camera) {
public postRender(camera: Phaser.Camera) {
// This could have been over-written by a sprite, need to store elsewhere
if (this._ga > -1)
@ -142,7 +140,7 @@ module Phaser.Renderer.Canvas {
this._cos * this._fy, // scale y
this._dx, // translate x
this._dy // translate y
);
);
this._dx = camera.transform.origin.x * -this._dw;
this._dy = camera.transform.origin.y * -this._dh;
@ -178,7 +176,7 @@ module Phaser.Renderer.Canvas {
this._dy, // Destination Y
this._dw, // Destination Width (always same as Source Width unless scaled)
this._dh // Destination Height (always same as Source Height unless scaled)
);
);
this.game.stage.context.restore();

View file

@ -0,0 +1,19 @@
var Shapes;
(function (Shapes) {
var Point = Shapes.Point = (function () {
function Point(x, y) {
this.x = x;
this.y = y;
}
Point.prototype.getDist = function () {
return Math.sqrt((this.x * this.x) + (this.y * this.y));
};
Point.origin = new Point(0, 0);
return Point;
})();
})(Shapes || (Shapes = {}));
var p = new Shapes.Point(3, 4);
var dist = p.getDist();

View file

@ -1,14 +1,4 @@
/// <reference path="../../Game.ts" />
/// <reference path="../../gameobjects/Sprite.ts" />
/// <reference path="../../gameobjects/ScrollZone.ts" />
/// <reference path="../../cameras/Camera.ts" />
/// <reference path="../IRenderer.ts" />
/// <reference path="CameraRenderer.ts" />
/// <reference path="GeometryRenderer.ts" />
/// <reference path="GroupRenderer.ts" />
/// <reference path="ScrollZoneRenderer.ts" />
/// <reference path="SpriteRenderer.ts" />
/// <reference path="TilemapRenderer.ts" />
/// <reference path="../../_definitions.ts" />
module Phaser.Renderer.Canvas {
@ -18,12 +8,12 @@ module Phaser.Renderer.Canvas {
this.game = game;
this.cameraRenderer = new CameraRenderer(game);
this.groupRenderer = new GroupRenderer(game);
this.spriteRenderer = new SpriteRenderer(game);
this.geometryRenderer = new GeometryRenderer(game);
this.scrollZoneRenderer = new ScrollZoneRenderer(game);
this.tilemapRenderer = new TilemapRenderer(game);
this.cameraRenderer = new Phaser.Renderer.Canvas.CameraRenderer(game);
this.groupRenderer = new Phaser.Renderer.Canvas.GroupRenderer(game);
this.spriteRenderer = new Phaser.Renderer.Canvas.SpriteRenderer(game);
this.geometryRenderer = new Phaser.Renderer.Canvas.GeometryRenderer(game);
this.scrollZoneRenderer = new Phaser.Renderer.Canvas.ScrollZoneRenderer(game);
this.tilemapRenderer = new Phaser.Renderer.Canvas.TilemapRenderer(game);
}
@ -31,7 +21,7 @@ module Phaser.Renderer.Canvas {
private _c: number = 0;
private _cameraList: Phaser.Camera[];
private _camera: Camera;
private _camera: Phaser.Camera;
public cameraRenderer: Phaser.Renderer.Canvas.CameraRenderer;
public groupRenderer: Phaser.Renderer.Canvas.GroupRenderer;
@ -65,7 +55,7 @@ module Phaser.Renderer.Canvas {
}
public renderGameObject(camera, object) {
public renderGameObject(camera:Phaser.Camera, object) {
if (object.type == Types.SPRITE || object.type == Types.BUTTON)
{

View file

@ -0,0 +1,19 @@
var Shapes;
(function (Shapes) {
var Point = Shapes.Point = (function () {
function Point(x, y) {
this.x = x;
this.y = y;
}
Point.prototype.getDist = function () {
return Math.sqrt((this.x * this.x) + (this.y * this.y));
};
Point.origin = new Point(0, 0);
return Point;
})();
})(Shapes || (Shapes = {}));
var p = new Shapes.Point(3, 4);
var dist = p.getDist();

View file

@ -1,6 +1,4 @@
/// <reference path="../../Game.ts" />
/// <reference path="../../gameobjects/Sprite.ts" />
/// <reference path="../../cameras/Camera.ts" />
/// <reference path="../../_definitions.ts" />
module Phaser.Renderer.Canvas {
@ -30,7 +28,7 @@ module Phaser.Renderer.Canvas {
private _sin: number = 0;
private _cos: number = 1;
public renderCircle(camera: Camera, circle: Circle, context, outline: boolean = false, fill: boolean = true, lineColor: string = 'rgb(0,255,0)', fillColor: string = 'rgba(0,100,0.0.3)', lineWidth: number = 1): boolean {
public renderCircle(camera: Phaser.Camera, circle: Phaser.Circle, context, outline: boolean = false, fill: boolean = true, lineColor: string = 'rgb(0,255,0)', fillColor: string = 'rgba(0,100,0.0.3)', lineWidth: number = 1): boolean {
// Reset our temp vars
this._sx = 0;

View file

@ -0,0 +1,19 @@
var Shapes;
(function (Shapes) {
var Point = Shapes.Point = (function () {
function Point(x, y) {
this.x = x;
this.y = y;
}
Point.prototype.getDist = function () {
return Math.sqrt((this.x * this.x) + (this.y * this.y));
};
Point.origin = new Point(0, 0);
return Point;
})();
})(Shapes || (Shapes = {}));
var p = new Shapes.Point(3, 4);
var dist = p.getDist();

View file

@ -1,6 +1,4 @@
/// <reference path="../../Game.ts" />
/// <reference path="../../gameobjects/Sprite.ts" />
/// <reference path="../../cameras/Camera.ts" />
/// <reference path="../../_definitions.ts" />
module Phaser.Renderer.Canvas {
@ -30,7 +28,7 @@ module Phaser.Renderer.Canvas {
private _sin: number = 0;
private _cos: number = 1;
public preRender(camera: Camera, group: Group) {
public preRender(camera: Phaser.Camera, group: Phaser.Group) {
if (group.visible == false || camera.transform.scale.x == 0 || camera.transform.scale.y == 0 || camera.texture.alpha < 0.1)
{
@ -98,7 +96,7 @@ module Phaser.Renderer.Canvas {
this._cos * this._fy, // scale y
this._dx, // translate x
this._dy // translate y
);
);
this._dx = -group.transform.origin.x;
this._dy = -group.transform.origin.y;
@ -139,14 +137,14 @@ module Phaser.Renderer.Canvas {
this._dy, // Destination Y
this._dw, // Destination Width (always same as Source Width unless scaled)
this._dh // Destination Height (always same as Source Height unless scaled)
);
);
}
return true;
}
public postRender(camera: Camera, group: Group) {
public postRender(camera: Phaser.Camera, group: Phaser.Group) {
if (group.modified || group.texture.globalCompositeOperation)
{

View file

@ -0,0 +1,19 @@
var Shapes;
(function (Shapes) {
var Point = Shapes.Point = (function () {
function Point(x, y) {
this.x = x;
this.y = y;
}
Point.prototype.getDist = function () {
return Math.sqrt((this.x * this.x) + (this.y * this.y));
};
Point.origin = new Point(0, 0);
return Point;
})();
})(Shapes || (Shapes = {}));
var p = new Shapes.Point(3, 4);
var dist = p.getDist();

View file

@ -1,6 +1,4 @@
/// <reference path="../../Game.ts" />
/// <reference path="../../gameobjects/Sprite.ts" />
/// <reference path="../../cameras/Camera.ts" />
/// <reference path="../../_definitions.ts" />
module Phaser.Renderer.Canvas {
@ -35,7 +33,7 @@ module Phaser.Renderer.Canvas {
* @param camera {Rectangle} The Rectangle you want to check.
* @return {boolean} Return true if bounds of this sprite intersects the given Rectangle, otherwise return false.
*/
public inCamera(camera: Camera, scrollZone: ScrollZone): boolean {
public inCamera(camera: Phaser.Camera, scrollZone: Phaser.ScrollZone): boolean {
// Object fixed in place regardless of the camera scrolling? Then it's always visible
if (scrollZone.transform.scrollFactor.equals(0))
@ -48,7 +46,7 @@ module Phaser.Renderer.Canvas {
}
public render(camera: Camera, scrollZone: ScrollZone): boolean {
public render(camera: Phaser.Camera, scrollZone: Phaser.ScrollZone): boolean {
if (scrollZone.transform.scale.x == 0 || scrollZone.transform.scale.y == 0 || scrollZone.texture.alpha < 0.1 || this.inCamera(camera, scrollZone) == false)
{
@ -107,7 +105,7 @@ module Phaser.Renderer.Canvas {
this._cos * this._fy, // scale y
this._dx, // translate x
this._dy // translate y
);
);
this._dx = -scrollZone.transform.origin.x;
this._dy = -scrollZone.transform.origin.y;

View file

@ -0,0 +1,19 @@
var Shapes;
(function (Shapes) {
var Point = Shapes.Point = (function () {
function Point(x, y) {
this.x = x;
this.y = y;
}
Point.prototype.getDist = function () {
return Math.sqrt((this.x * this.x) + (this.y * this.y));
};
Point.origin = new Point(0, 0);
return Point;
})();
})(Shapes || (Shapes = {}));
var p = new Shapes.Point(3, 4);
var dist = p.getDist();

View file

@ -1,6 +1,4 @@
/// <reference path="../../Game.ts" />
/// <reference path="../../gameobjects/Sprite.ts" />
/// <reference path="../../cameras/Camera.ts" />
/// <reference path="../../_definitions.ts" />
module Phaser.Renderer.Canvas {
@ -32,7 +30,7 @@ module Phaser.Renderer.Canvas {
* @param camera {Rectangle} The Rectangle you want to check.
* @return {boolean} Return true if bounds of this sprite intersects the given Rectangle, otherwise return false.
*/
public inCamera(camera: Camera, sprite: Sprite): boolean {
public inCamera(camera: Phaser.Camera, sprite: Phaser.Sprite): boolean {
// Object fixed in place regardless of the camera scrolling? Then it's always visible
if (sprite.transform.scrollFactor.equals(0))
@ -50,7 +48,7 @@ module Phaser.Renderer.Canvas {
* @param camera {Camera} Camera this sprite will be rendered to.
* @return {boolean} Return false if not rendered, otherwise return true.
*/
public render(camera: Camera, sprite: Sprite): boolean {
public render(camera: Phaser.Camera, sprite: Phaser.Sprite): boolean {
Phaser.SpriteUtils.updateCameraView(camera, sprite);
@ -99,7 +97,7 @@ module Phaser.Renderer.Canvas {
sprite.transform.local.data[4], // scale y
this._dx, // translate x
this._dy // translate y
);
);
this._dx = sprite.transform.origin.x * -this._dw;
this._dy = sprite.transform.origin.y * -this._dh;
@ -168,9 +166,9 @@ module Phaser.Renderer.Canvas {
this._dy, // Destination Y
this._dw, // Destination Width (always same as Source Width unless scaled)
this._dh // Destination Height (always same as Source Height unless scaled)
);
);
}
if (sprite.modified || sprite.texture.globalCompositeOperation)
{
camera.texture.context.restore();

View file

@ -0,0 +1,19 @@
var Shapes;
(function (Shapes) {
var Point = Shapes.Point = (function () {
function Point(x, y) {
this.x = x;
this.y = y;
}
Point.prototype.getDist = function () {
return Math.sqrt((this.x * this.x) + (this.y * this.y));
};
Point.origin = new Point(0, 0);
return Point;
})();
})(Shapes || (Shapes = {}));
var p = new Shapes.Point(3, 4);
var dist = p.getDist();

View file

@ -1,6 +1,4 @@
/// <reference path="../../Game.ts" />
/// <reference path="../../gameobjects/Sprite.ts" />
/// <reference path="../../cameras/Camera.ts" />
/// <reference path="../../_definitions.ts" />
module Phaser.Renderer.Canvas {
@ -34,7 +32,7 @@ module Phaser.Renderer.Canvas {
* Render a tilemap to a specific camera.
* @param camera {Camera} The camera this tilemap will be rendered to.
*/
public render(camera: Camera, tilemap: Tilemap): boolean {
public render(camera: Phaser.Camera, tilemap: Phaser.Tilemap): boolean {
// Loop through the layers
@ -127,7 +125,7 @@ module Phaser.Renderer.Canvas {
this._ty,
layer.tileWidth,
layer.tileHeight
);
);
}

View file

@ -1,5 +1,4 @@
/// <reference path="../Game.ts" />
/// <reference path="SoundManager.ts" />
/// <reference path="../_definitions.ts" />
/**
* Phaser - Sound
@ -69,7 +68,7 @@ module Phaser {
}
private soundHasUnlocked(key:string) {
private soundHasUnlocked(key: string) {
if (key == this.key)
{
@ -83,7 +82,7 @@ module Phaser {
/**
* Local reference to the current Phaser.Game.
*/
public game: Game;
public game: Phaser.Game;
/**
* Reference to AudioContext instance.
@ -312,10 +311,10 @@ module Phaser {
//if (this._sound == null)
//{
this._sound = this.context.createBufferSource();
this._sound.buffer = this._buffer;
this._sound.connect(this.gainNode);
this.totalDuration = this._sound.buffer.duration;
this._sound = this.context.createBufferSource();
this._sound.buffer = this._buffer;
this._sound.connect(this.gainNode);
this.totalDuration = this._sound.buffer.duration;
//}
if (this.duration == 0)
@ -480,7 +479,7 @@ module Phaser {
this.isPlaying = false;
var prevMarker:string = this.currentMarker;
var prevMarker: string = this.currentMarker;
this.currentMarker = '';

View file

@ -1,5 +1,4 @@
/// <reference path="../Game.ts" />
/// <reference path="Sound.ts" />
/// <reference path="../_definitions.ts" />
/**
* Phaser - SoundManager
@ -14,7 +13,7 @@ module Phaser {
* SoundManager constructor
* Create a new <code>SoundManager</code>.
*/
constructor(game: Game) {
constructor(game: Phaser.Game) {
this.game = game;
@ -29,7 +28,6 @@ module Phaser {
if (this.game.device.iOS || (window['PhaserGlobal'] && window['PhaserGlobal'].fakeiOSTouchLock))
{
//console.log('iOS Touch Locked');
this.game.input.touch.callbackContext = this;
this.game.input.touch.touchStartCallback = this.unlock;
this.game.input.mouse.callbackContext = this;
@ -109,7 +107,7 @@ module Phaser {
/**
* Local reference to the current Phaser.Game.
*/
public game: Game;
public game: Phaser.Game;
/**
* Reference to AudioContext instance.
@ -149,7 +147,6 @@ module Phaser {
if (this.game.device.webAudio && (window['PhaserGlobal'] && window['PhaserGlobal'].disableWebAudio == false))
{
//console.log('create empty buffer');
// Create empty buffer and play it
var buffer = this.context.createBuffer(1, 1, 22050);
this._unlockSource = this.context.createBufferSource();
@ -160,7 +157,6 @@ module Phaser {
else
{
// Create an Audio tag?
//console.log('create audio tag');
this.touchLocked = false;
this._unlockSource = null;
this.game.input.touch.callbackContext = null;
@ -180,8 +176,6 @@ module Phaser {
public set mute(value: boolean) {
console.log('SoundManager mute', value);
if (value)
{
if (this._muted)

View file

@ -1,4 +1,4 @@
/// <reference path="../Game.ts" />
/// <reference path="../_definitions.ts" />
/**
* Phaser - Device
@ -25,8 +25,6 @@ module Phaser {
}
// Android bug specific :)
/**
* An optional 'fix' for the horrendous Android stock browser bug
* https://code.google.com/p/android/issues/detail?id=39247
@ -549,65 +547,6 @@ module Phaser {
}
/**
* Get all informations of host device.
* @return {string} Informations in a string.
*/
public getAll(): string {
var output: string = '';
output = output.concat('Device\n');
output = output.concat('iPhone : ' + this.iPhone + '\n');
output = output.concat('iPhone4 : ' + this.iPhone4 + '\n');
output = output.concat('iPad : ' + this.iPad + '\n');
output = output.concat('\n');
output = output.concat('Operating System\n');
output = output.concat('iOS: ' + this.iOS + '\n');
output = output.concat('Android: ' + this.android + '\n');
output = output.concat('ChromeOS: ' + this.chromeOS + '\n');
output = output.concat('Linux: ' + this.linux + '\n');
output = output.concat('MacOS: ' + this.macOS + '\n');
output = output.concat('Windows: ' + this.windows + '\n');
output = output.concat('\n');
output = output.concat('Browser\n');
output = output.concat('Arora: ' + this.arora + '\n');
output = output.concat('Chrome: ' + this.chrome + '\n');
output = output.concat('Epiphany: ' + this.epiphany + '\n');
output = output.concat('Firefox: ' + this.firefox + '\n');
output = output.concat('Internet Explorer: ' + this.ie + ' (' + this.ieVersion + ')\n');
output = output.concat('Mobile Safari: ' + this.mobileSafari + '\n');
output = output.concat('Midori: ' + this.midori + '\n');
output = output.concat('Opera: ' + this.opera + '\n');
output = output.concat('Safari: ' + this.safari + '\n');
output = output.concat('\n');
output = output.concat('Features\n');
output = output.concat('Canvas: ' + this.canvas + '\n');
output = output.concat('File: ' + this.file + '\n');
output = output.concat('FileSystem: ' + this.fileSystem + '\n');
output = output.concat('LocalStorage: ' + this.localStorage + '\n');
output = output.concat('WebGL: ' + this.webGL + '\n');
output = output.concat('Worker: ' + this.worker + '\n');
output = output.concat('Touch: ' + this.touch + '\n');
output = output.concat('MSPointer: ' + this.mspointer + '\n');
output = output.concat('CSS 3D: ' + this.css3D + '\n');
output = output.concat('\n');
output = output.concat('Audio\n');
output = output.concat('Audio Data: ' + this.canvas + '\n');
output = output.concat('Web Audio: ' + this.canvas + '\n');
output = output.concat('Can play OGG: ' + this.canvas + '\n');
output = output.concat('Can play MP3: ' + this.canvas + '\n');
output = output.concat('Can play M4A: ' + this.canvas + '\n');
output = output.concat('Can play WAV: ' + this.canvas + '\n');
return output;
}
}
}

View file

@ -1,4 +1,4 @@
/// <reference path="../Game.ts" />
/// <reference path="../_definitions.ts" />
/**
* Phaser - RequestAnimationFrame
@ -15,7 +15,7 @@ module Phaser {
* @param {Any} callback
* @return {RequestAnimationFrame} This object.
*/
constructor(game: Game, callback) {
constructor(game: Phaser.Game, callback) {
this.game = game;
this.callback = callback;
@ -35,7 +35,7 @@ module Phaser {
/**
* Local reference to Game.
*/
public game: Game;
public game: Phaser.Game;
/**
* The function to be called each frame. Will be called in the context of _game

View file

@ -1,4 +1,4 @@
/// <reference path="../Game.ts" />
/// <reference path="../_definitions.ts" />
/**
* Phaser - StageScaleMode
@ -15,12 +15,12 @@ module Phaser {
/**
* StageScaleMode constructor
*/
constructor(game: Game, width: number, height: number) {
constructor(game: Phaser.Game, width: number, height: number) {
this.game = game;
this.enterLandscape = new Phaser.Signal();
this.enterPortrait = new Phaser.Signal();
this.enterLandscape = new Phaser.Signal;
this.enterPortrait = new Phaser.Signal;
if (window['orientation'])
{
@ -38,7 +38,7 @@ module Phaser {
}
}
this.scaleFactor = new Vec2(1, 1);
this.scaleFactor = new Phaser.Vec2(1, 1);
this.aspectRatio = 0;
this.minWidth = width;
this.minHeight = height;
@ -53,7 +53,7 @@ module Phaser {
/**
* Local reference to Game.
*/
public game: Game;
public game: Phaser.Game;
/**
* Stage height when start the game.
@ -169,7 +169,7 @@ module Phaser {
* The scale factor of the scaled game width
* @type {Vec2}
*/
public scaleFactor: Vec2;
public scaleFactor: Phaser.Vec2;
/**
* Window orientation angle (90 and -90 are landscape, 0 and 80 are portrait)
@ -247,7 +247,7 @@ module Phaser {
*/
public update() {
if (this.game.stage.scaleMode !== StageScaleMode.NO_SCALE && (window.innerWidth !== this.width || window.innerHeight !== this.height))
if (this.game.stage.scaleMode !== Phaser.StageScaleMode.NO_SCALE && (window.innerWidth !== this.width || window.innerHeight !== this.height))
{
this.refresh();
}

View file

@ -1,4 +1,4 @@
/// <reference path="../../Game.ts" />
/// <reference path="../../_definitions.ts" />
/**
* Phaser - BootScreen
@ -17,7 +17,7 @@ module Phaser {
* @param width {number} Screen canvas width.
* @param height {number} Screen canvas height.
*/
constructor(game:Game) {
constructor(game: Phaser.Game) {
this.game = game;
@ -29,23 +29,28 @@ module Phaser {
/**
* Local reference to Game.
*/
public game: Game;
public game: Phaser.Game;
/**
* Engine logo.
*/
private _logo;
/**
* Engine logo image data.
*/
private _logoData: string = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGgAAAAZCAYAAADdYmvFAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAstJREFUeNrsWlFuwjAMbavdZGcAcRm4AXzvCPuGG8BlEJxhZ+l4TJ48z3actGGthqUI1MaO/V6cmIT2/fW10eTt46NvKshtvDZlG31yfOL9a/ldU6x4IZ0GQs0gS217enMkJYr5ixXkYrFoVqtV1kDn8/n+KfXw/Hq9Nin7h8MhScB2u3Xtav2ivsNWrh7XLcWMYqA4eUZ1kj0MAifHJEeKFojWzyIH+rL/0Cwif2AX9nN1oQOgrTg8XcTFx+ScdEOJ4WBxXQ1EjRyrn0cOzzQLzFyQSQcgw/5Qkkr0JVEQpNIdhL4vm4DL5fLulNTHcy6Uxl4/6iMLiePx2KzX6/v30+n0aynUlrnSeNq2/VN9bgM4dFPdNPmsJnIg/PuQbJmLdFN3UNu0SzbyJ0GOWJVWZE/QMkY+owrqXxGEdZA37BVyX6lJTipT6J1lf7fbqc+xh8nYeIvikatP+PGW0nEJ4jOydHYOIcfKnmgWoZDQSIIeio4Sf1IthYWskCO4vqQ6lFYjl8tl9L1H67PZbMz3VO3t93uVXHofmUjReLyMwHi5eCb3ICwJj5ZU9nCg+SzUgPYyif+2epTk4pkkyDp+eXTlZu2BkUybEkklePZfK9lPuTnc07vbmt1bYulHBeNQgx18SsH4ni/cV2rSLtqNDNUH2JQ2SsXS57Y9PHlfumkwCdICt5rnkNdPjpMiIEWgRlAJSdF4SvCQMWj+VyfI0h8D/EgWSYKiJKXi8VrOhJUxaFiFCOKKUJAtR78k9eX4USLHXqLGXOIiWUT4Vj9JiP4W0io3VDz8AJXblNWQrOimLjIGy/9uLICH6mrVmFbxEFHauzmc0fGJJmPg/v+6D0oB7N2bj0FsNHtSWTQniWTR931QlHXvasDTHXLjqY0/1/8hSDxACD+lAGH8dKQbQk5N3TFtzDmLWutvV0+pL5FVoHvCNG35FGAAayS4KUoKC9QAAAAASUVORK5CYII=";
/**
* Background gradient effect color 1.
*/
private _color1 = { r: 20, g: 20, b: 20 };
/**
* Background gradient effect color 2.
*/
private _color2 = { r: 200, g: 200, b: 200 };
/**
* Fade effect tween.
* @type {Phaser.Tween}

View file

@ -1,4 +1,4 @@
/// <reference path="../../Game.ts" />
/// <reference path="../../_definitions.ts" />
/**
* Phaser - OrientationScreen
@ -17,14 +17,14 @@ module Phaser {
* @param width {number} Screen canvas width.
* @param height {number} Screen canvas height.
*/
constructor(game: Game) {
constructor(game: Phaser.Game) {
this.game = game;
}
/**
* Local reference to game.
*/
public game: Game;
public game: Phaser.Game;
private _showOnLandscape: boolean = false;
private _showOnPortrait: boolean = false;

View file

@ -1,4 +1,4 @@
/// <reference path="../../Game.ts" />
/// <reference path="../../_definitions.ts" />
/**
* Phaser - PauseScreen
@ -17,7 +17,7 @@ module Phaser {
* @param width {number} Screen canvas width.
* @param height {number} Screen canvas height.
*/
constructor(game: Game, width: number, height: number) {
constructor(game: Phaser.Game, width: number, height: number) {
this.game = game;
this._canvas = <HTMLCanvasElement> document.createElement('canvas');
@ -30,7 +30,7 @@ module Phaser {
/**
* Local reference to Game.
*/
public game: Game;
public game: Phaser.Game;
/**
* Canvas element used by engine.

134
Phaser/tilemap/Tile.js Normal file
View file

@ -0,0 +1,134 @@
/// <reference path="../_definitions.ts" />
/**
* Phaser - Tile
*
* A Tile is a single representation of a tile within a Tilemap
*/
var Phaser;
(function (Phaser) {
var Tile = (function () {
/**
* Tile constructor
* Create a new <code>Tile</code>.
*
* @param tilemap {Tilemap} the tilemap this tile belongs to.
* @param index {number} The index of this tile type in the core map data.
* @param width {number} Width of the tile.
* @param height number} Height of the tile.
*/
function Tile(game, tilemap, index, width, height) {
/**
* The virtual mass of the tile.
* @type {number}
*/
this.mass = 1.0;
/**
* Indicating collide with any object on the left.
* @type {boolean}
*/
this.collideLeft = false;
/**
* Indicating collide with any object on the right.
* @type {boolean}
*/
this.collideRight = false;
/**
* Indicating collide with any object on the top.
* @type {boolean}
*/
this.collideUp = false;
/**
* Indicating collide with any object on the bottom.
* @type {boolean}
*/
this.collideDown = false;
/**
* Enable separation at x-axis.
* @type {boolean}
*/
this.separateX = true;
/**
* Enable separation at y-axis.
* @type {boolean}
*/
this.separateY = true;
this.game = game;
this.tilemap = tilemap;
this.index = index;
this.width = width;
this.height = height;
this.allowCollisions = Phaser.Types.NONE;
}
/**
* Clean up memory.
*/
Tile.prototype.destroy = function () {
this.tilemap = null;
};
/**
* Set collision configs.
* @param collision {number} Bit field of flags. (see Tile.allowCollision)
* @param resetCollisions {boolean} Reset collision flags before set.
* @param separateX {boolean} Enable seprate at x-axis.
* @param separateY {boolean} Enable seprate at y-axis.
*/
Tile.prototype.setCollision = function (collision, resetCollisions, separateX, separateY) {
if (resetCollisions) {
this.resetCollision();
}
this.separateX = separateX;
this.separateY = separateY;
this.allowCollisions = collision;
if (collision & Phaser.Types.ANY) {
this.collideLeft = true;
this.collideRight = true;
this.collideUp = true;
this.collideDown = true;
return;
}
if (collision & Phaser.Types.LEFT || collision & Phaser.Types.WALL) {
this.collideLeft = true;
}
if (collision & Phaser.Types.RIGHT || collision & Phaser.Types.WALL) {
this.collideRight = true;
}
if (collision & Phaser.Types.UP || collision & Phaser.Types.CEILING) {
this.collideUp = true;
}
if (collision & Phaser.Types.DOWN || collision & Phaser.Types.CEILING) {
this.collideDown = true;
}
};
/**
* Reset collision status flags.
*/
Tile.prototype.resetCollision = function () {
this.allowCollisions = Phaser.Types.NONE;
this.collideLeft = false;
this.collideRight = false;
this.collideUp = false;
this.collideDown = false;
};
/**
* Returns a string representation of this object.
* @method toString
* @return {string} a string representation of the object.
**/
Tile.prototype.toString = function () {
return "[{Tiled (index=" + this.index + " collisions=" + this.allowCollisions + " width=" + this.width + " height=" + this.height + ")}]";
};
return Tile;
})();
Phaser.Tile = Tile;
})(Phaser || (Phaser = {}));

View file

@ -1,4 +1,4 @@
/// <reference path="../Game.ts" />
/// <reference path="../_definitions.ts" />
/**
* Phaser - Tile
@ -19,7 +19,7 @@ module Phaser {
* @param width {number} Width of the tile.
* @param height number} Height of the tile.
*/
constructor(game: Game, tilemap: Tilemap, index: number, width: number, height: number) {
constructor(game: Phaser.Game, tilemap: Phaser.Tilemap, index: number, width: number, height: number) {
this.game = game;
this.tilemap = tilemap;
@ -34,7 +34,7 @@ module Phaser {
/**
* Local reference to Game.
*/
public game: Game;
public game: Phaser.Game;
/**
* You can give this Tile a friendly name to help with debugging. Never used internally.
@ -106,7 +106,7 @@ module Phaser {
* A reference to the tilemap this tile object belongs to.
* @type {Tilemap}
*/
public tilemap: Tilemap;
public tilemap: Phaser.Tilemap;
/**
* The index of this tile type in the core map data.
@ -144,7 +144,7 @@ module Phaser {
this.allowCollisions = collision;
if (collision & Types.ANY)
if (collision & Phaser.Types.ANY)
{
this.collideLeft = true;
this.collideRight = true;
@ -153,22 +153,22 @@ module Phaser {
return;
}
if (collision & Types.LEFT || collision & Types.WALL)
if (collision & Phaser.Types.LEFT || collision & Phaser.Types.WALL)
{
this.collideLeft = true;
}
if (collision & Types.RIGHT || collision & Types.WALL)
if (collision & Phaser.Types.RIGHT || collision & Phaser.Types.WALL)
{
this.collideRight = true;
}
if (collision & Types.UP || collision & Types.CEILING)
if (collision & Phaser.Types.UP || collision & Phaser.Types.CEILING)
{
this.collideUp = true;
}
if (collision & Types.DOWN || collision & Types.CEILING)
if (collision & Phaser.Types.DOWN || collision & Phaser.Types.CEILING)
{
this.collideDown = true;
}
@ -180,7 +180,7 @@ module Phaser {
*/
public resetCollision() {
this.allowCollisions = Types.NONE;
this.allowCollisions = Phaser.Types.NONE;
this.collideLeft = false;
this.collideRight = false;
this.collideUp = false;
@ -195,7 +195,7 @@ module Phaser {
**/
public toString(): string {
return "[{Tiled (index=" + this.index + " collisions=" + this.allowCollisions + " width=" + this.width + " height=" + this.height + ")}]";
return "[{Tile (index=" + this.index + " collisions=" + this.allowCollisions + " width=" + this.width + " height=" + this.height + ")}]";
}

366
Phaser/tilemap/Tilemap.js Normal file
View file

@ -0,0 +1,366 @@
/// <reference path="../_definitions.ts" />
/**
* Phaser - Tilemap
*
* This GameObject allows for the display of a tilemap within the game world. Tile maps consist of an image, tile data and a size.
* Internally it creates a TilemapLayer for each layer in the tilemap.
*/
var Phaser;
(function (Phaser) {
var Tilemap = (function () {
/**
* Tilemap constructor
* Create a new <code>Tilemap</code>.
*
* @param game {Phaser.Game} Current game instance.
* @param key {string} Asset key for this map.
* @param mapData {string} Data of this map. (a big 2d array, normally in csv)
* @param format {number} Format of this map data, available: Tilemap.FORMAT_CSV or Tilemap.FORMAT_TILED_JSON.
* @param resizeWorld {boolean} Resize the world bound automatically based on this tilemap?
* @param tileWidth {number} Width of tiles in this map.
* @param tileHeight {number} Height of tiles in this map.
*/
function Tilemap(game, key, mapData, format, resizeWorld, tileWidth, tileHeight) {
if (typeof resizeWorld === "undefined") { resizeWorld = true; }
if (typeof tileWidth === "undefined") { tileWidth = 0; }
if (typeof tileHeight === "undefined") { tileHeight = 0; }
/**
* z order value of the object.
*/
this.z = -1;
/**
* Render iteration counter
*/
this.renderOrderID = 0;
/**
* Tilemap collision callback.
* @type {function}
*/
this.collisionCallback = null;
this.game = game;
this.type = Phaser.Types.TILEMAP;
this.exists = true;
this.active = true;
this.visible = true;
this.alive = true;
this.z = -1;
this.group = null;
this.name = '';
this.texture = new Phaser.Display.Texture(this);
this.transform = new Phaser.Components.TransformManager(this);
this.tiles = [];
this.layers = [];
this.mapFormat = format;
switch (format) {
case Tilemap.FORMAT_CSV:
this.parseCSV(game.cache.getText(mapData), key, tileWidth, tileHeight);
break;
case Tilemap.FORMAT_TILED_JSON:
this.parseTiledJSON(game.cache.getText(mapData), key);
break;
}
if (this.currentLayer && resizeWorld) {
this.game.world.setSize(this.currentLayer.widthInPixels, this.currentLayer.heightInPixels, true);
}
}
/**
* Parset csv map data and generate tiles.
* @param data {string} CSV map data.
* @param key {string} Asset key for tileset image.
* @param tileWidth {number} Width of its tile.
* @param tileHeight {number} Height of its tile.
*/
Tilemap.prototype.parseCSV = function (data, key, tileWidth, tileHeight) {
var layer = new TilemapLayer(this, 0, key, Tilemap.FORMAT_CSV, 'TileLayerCSV' + this.layers.length.toString(), tileWidth, tileHeight);
// Trim any rogue whitespace from the data
data = data.trim();
var rows = data.split("\n");
for (var i = 0; i < rows.length; i++) {
var column = rows[i].split(",");
if (column.length > 0) {
layer.addColumn(column);
}
}
layer.updateBounds();
var tileQuantity = layer.parseTileOffsets();
this.currentLayer = layer;
this.collisionLayer = layer;
this.layers.push(layer);
this.generateTiles(tileQuantity);
};
/**
* Parse JSON map data and generate tiles.
* @param data {string} JSON map data.
* @param key {string} Asset key for tileset image.
*/
Tilemap.prototype.parseTiledJSON = function (data, key) {
// Trim any rogue whitespace from the data
data = data.trim();
var json = JSON.parse(data);
for (var i = 0; i < json.layers.length; i++) {
var layer = new TilemapLayer(this, i, key, Tilemap.FORMAT_TILED_JSON, json.layers[i].name, json.tilewidth, json.tileheight);
if (!json.layers[i].data) {
continue;
}
layer.alpha = json.layers[i].opacity;
layer.visible = json.layers[i].visible;
layer.tileMargin = json.tilesets[0].margin;
layer.tileSpacing = json.tilesets[0].spacing;
var c = 0;
var row;
for (var t = 0; t < json.layers[i].data.length; t++) {
if (c == 0) {
row = [];
}
row.push(json.layers[i].data[t]);
c++;
if (c == json.layers[i].width) {
layer.addColumn(row);
c = 0;
}
}
layer.updateBounds();
var tileQuantity = layer.parseTileOffsets();
this.currentLayer = layer;
this.collisionLayer = layer;
this.layers.push(layer);
}
this.generateTiles(tileQuantity);
};
/**
* Create tiles of given quantity.
* @param qty {number} Quentity of tiles to be generated.
*/
Tilemap.prototype.generateTiles = function (qty) {
for (var i = 0; i < qty; i++) {
this.tiles.push(new Tile(this.game, this, i, this.currentLayer.tileWidth, this.currentLayer.tileHeight));
}
};
Object.defineProperty(Tilemap.prototype, "widthInPixels", {
get: function () {
return this.currentLayer.widthInPixels;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Tilemap.prototype, "heightInPixels", {
get: function () {
return this.currentLayer.heightInPixels;
},
enumerable: true,
configurable: true
});
// Tile Collision
/**
* Set callback to be called when this tilemap collides.
* @param context {object} Callback will be called with this context.
* @param callback {function} Callback function.
*/
Tilemap.prototype.setCollisionCallback = function (context, callback) {
this.collisionCallbackContext = context;
this.collisionCallback = callback;
};
/**
* Set collision configs of tiles in a range index.
* @param start {number} First index of tiles.
* @param end {number} Last index of tiles.
* @param collision {number} Bit field of flags. (see Tile.allowCollision)
* @param resetCollisions {boolean} Reset collision flags before set.
* @param separateX {boolean} Enable seprate at x-axis.
* @param separateY {boolean} Enable seprate at y-axis.
*/
Tilemap.prototype.setCollisionRange = function (start, end, collision, resetCollisions, separateX, separateY) {
if (typeof collision === "undefined") { collision = Phaser.Types.ANY; }
if (typeof resetCollisions === "undefined") { resetCollisions = false; }
if (typeof separateX === "undefined") { separateX = true; }
if (typeof separateY === "undefined") { separateY = true; }
for (var i = start; i < end; i++) {
this.tiles[i].setCollision(collision, resetCollisions, separateX, separateY);
}
};
/**
* Set collision configs of tiles with given index.
* @param values {number[]} Index array which contains all tile indexes. The tiles with those indexes will be setup with rest parameters.
* @param collision {number} Bit field of flags. (see Tile.allowCollision)
* @param resetCollisions {boolean} Reset collision flags before set.
* @param separateX {boolean} Enable seprate at x-axis.
* @param separateY {boolean} Enable seprate at y-axis.
*/
Tilemap.prototype.setCollisionByIndex = function (values, collision, resetCollisions, separateX, separateY) {
if (typeof collision === "undefined") { collision = Phaser.Types.ANY; }
if (typeof resetCollisions === "undefined") { resetCollisions = false; }
if (typeof separateX === "undefined") { separateX = true; }
if (typeof separateY === "undefined") { separateY = true; }
for (var i = 0; i < values.length; i++) {
this.tiles[values[i]].setCollision(collision, resetCollisions, separateX, separateY);
}
};
// Tile Management
/**
* Get the tile by its index.
* @param value {number} Index of the tile you want to get.
* @return {Tile} The tile with given index.
*/
Tilemap.prototype.getTileByIndex = function (value) {
if (this.tiles[value]) {
return this.tiles[value];
}
return null;
};
/**
* Get the tile located at specific position and layer.
* @param x {number} X position of this tile located.
* @param y {number} Y position of this tile located.
* @param [layer] {number} layer of this tile located.
* @return {Tile} The tile with specific properties.
*/
Tilemap.prototype.getTile = function (x, y, layer) {
if (typeof layer === "undefined") { layer = this.currentLayer.ID; }
return this.tiles[this.layers[layer].getTileIndex(x, y)];
};
/**
* Get the tile located at specific position (in world coordinate) and layer. (thus you give a position of a point which is within the tile)
* @param x {number} X position of the point in target tile.
* @param x {number} Y position of the point in target tile.
* @param [layer] {number} layer of this tile located.
* @return {Tile} The tile with specific properties.
*/
Tilemap.prototype.getTileFromWorldXY = function (x, y, layer) {
if (typeof layer === "undefined") { layer = this.currentLayer.ID; }
return this.tiles[this.layers[layer].getTileFromWorldXY(x, y)];
};
/**
* Gets the tile underneath the Input.x/y position
* @param layer The layer to check, defaults to 0
* @returns {Tile}
*/
Tilemap.prototype.getTileFromInputXY = function (layer) {
if (typeof layer === "undefined") { layer = this.currentLayer.ID; }
return this.tiles[this.layers[layer].getTileFromWorldXY(this.game.input.worldX, this.game.input.worldY)];
};
/**
* Get tiles overlaps the given object.
* @param object {GameObject} Tiles you want to get that overlaps this.
* @return {array} Array with tiles information. (Each contains x, y and the tile.)
*/
Tilemap.prototype.getTileOverlaps = function (object) {
return this.currentLayer.getTileOverlaps(object);
};
// COLLIDE
/**
* Check whether this tilemap collides with the given game object or group of objects.
* @param objectOrGroup {function} Target object of group you want to check.
* @param callback {function} This is called if objectOrGroup collides the tilemap.
* @param context {object} Callback will be called with this context.
* @return {boolean} Return true if this collides with given object, otherwise return false.
*/
Tilemap.prototype.collide = function (objectOrGroup, callback, context) {
if (typeof objectOrGroup === "undefined") { objectOrGroup = null; }
if (typeof callback === "undefined") { callback = null; }
if (typeof context === "undefined") { context = null; }
if (callback !== null && context !== null) {
this.collisionCallback = callback;
this.collisionCallbackContext = context;
}
if (objectOrGroup == null) {
objectOrGroup = this.game.world.group;
}
if (objectOrGroup.isGroup == false) {
this.collideGameObject(objectOrGroup);
} else {
objectOrGroup.forEachAlive(this, this.collideGameObject, true);
}
};
/**
* Check whether this tilemap collides with the given game object.
* @param object {GameObject} Target object you want to check.
* @return {boolean} Return true if this collides with given object, otherwise return false.
*/
Tilemap.prototype.collideGameObject = function (object) {
if (object.body.type == Phaser.Types.BODY_DYNAMIC && object.exists == true && object.body.allowCollisions != Phaser.Types.NONE) {
this._tempCollisionData = this.collisionLayer.getTileOverlaps(object);
if (this.collisionCallback !== null && this._tempCollisionData.length > 0) {
this.collisionCallback.call(this.collisionCallbackContext, object, this._tempCollisionData);
}
return true;
} else {
return false;
}
};
/**
* Set a tile to a specific layer.
* @param x {number} X position of this tile.
* @param y {number} Y position of this tile.
* @param index {number} The index of this tile type in the core map data.
* @param [layer] {number} which layer you want to set the tile to.
*/
Tilemap.prototype.putTile = function (x, y, index, layer) {
if (typeof layer === "undefined") { layer = this.currentLayer.ID; }
this.layers[layer].putTile(x, y, index);
};
Tilemap.prototype.destroy = function () {
this.texture = null;
this.transform = null;
this.tiles.length = 0;
this.layers.length = 0;
};
Tilemap.FORMAT_CSV = 0;
Tilemap.FORMAT_TILED_JSON = 1;
return Tilemap;
})();
Phaser.Tilemap = Tilemap;
})(Phaser || (Phaser = {}));

View file

@ -1,6 +1,4 @@
/// <reference path="../Game.ts" />
/// <reference path="TilemapLayer.ts" />
/// <reference path="Tile.ts" />
/// <reference path="../_definitions.ts" />
/**
* Phaser - Tilemap
@ -70,7 +68,7 @@ module Phaser {
/**
* Reference to the main game object
*/
public game: Game;
public game: Phaser.Game;
/**
* The type of game object.
@ -143,25 +141,25 @@ module Phaser {
* Array contains tile objects of this map.
* @type {Tile[]}
*/
public tiles : Tile[];
public tiles: Phaser.Tile[];
/**
* Array contains tilemap layer objects of this map.
* @type {TilemapLayer[]}
*/
public layers : TilemapLayer[];
public layers : Phaser.TilemapLayer[];
/**
* Current tilemap layer.
* @type {TilemapLayer}
*/
public currentLayer: TilemapLayer;
public currentLayer: Phaser.TilemapLayer;
/**
* The tilemap layer for collision.
* @type {TilemapLayer}
*/
public collisionLayer: TilemapLayer;
public collisionLayer: Phaser.TilemapLayer;
/**
* Tilemap collision callback.
@ -290,7 +288,7 @@ module Phaser {
for (var i = 0; i < qty; i++)
{
this.tiles.push(new Tile(this.game, this, i, this.currentLayer.tileWidth, this.currentLayer.tileHeight));
this.tiles.push(new Phaser.Tile(this.game, this, i, this.currentLayer.tileWidth, this.currentLayer.tileHeight));
}
}
@ -359,7 +357,7 @@ module Phaser {
* @param value {number} Index of the tile you want to get.
* @return {Tile} The tile with given index.
*/
public getTileByIndex(value: number):Tile {
public getTileByIndex(value: number): Phaser.Tile {
if (this.tiles[value])
{
@ -377,7 +375,7 @@ module Phaser {
* @param [layer] {number} layer of this tile located.
* @return {Tile} The tile with specific properties.
*/
public getTile(x: number, y: number, layer: number = this.currentLayer.ID):Tile {
public getTile(x: number, y: number, layer: number = this.currentLayer.ID): Phaser.Tile {
return this.tiles[this.layers[layer].getTileIndex(x, y)];
@ -390,7 +388,7 @@ module Phaser {
* @param [layer] {number} layer of this tile located.
* @return {Tile} The tile with specific properties.
*/
public getTileFromWorldXY(x: number, y: number, layer: number = this.currentLayer.ID):Tile {
public getTileFromWorldXY(x: number, y: number, layer: number = this.currentLayer.ID): Phaser.Tile {
return this.tiles[this.layers[layer].getTileFromWorldXY(x, y)];
@ -401,7 +399,7 @@ module Phaser {
* @param layer The layer to check, defaults to 0
* @returns {Tile}
*/
public getTileFromInputXY(layer: number = this.currentLayer.ID):Tile {
public getTileFromInputXY(layer: number = this.currentLayer.ID): Phaser.Tile {
return this.tiles[this.layers[layer].getTileFromWorldXY(this.game.input.worldX, this.game.input.worldY)];
@ -412,7 +410,7 @@ module Phaser {
* @param object {GameObject} Tiles you want to get that overlaps this.
* @return {array} Array with tiles information. (Each contains x, y and the tile.)
*/
public getTileOverlaps(object: Sprite) {
public getTileOverlaps(object: Phaser.Sprite) {
return this.currentLayer.getTileOverlaps(object);
@ -456,7 +454,7 @@ module Phaser {
* @param object {GameObject} Target object you want to check.
* @return {boolean} Return true if this collides with given object, otherwise return false.
*/
public collideGameObject(object: Sprite): boolean {
public collideGameObject(object: Phaser.Sprite): boolean {
if (object.body.type == Types.BODY_DYNAMIC && object.exists == true && object.body.allowCollisions != Types.NONE)
{

View file

@ -0,0 +1,395 @@
/// <reference path="../_definitions.ts" />
/**
* Phaser - TilemapLayer
*
* A Tilemap Layer. Tiled format maps can have multiple overlapping layers.
*/
var Phaser;
(function (Phaser) {
var TilemapLayer = (function () {
/**
* TilemapLayer constructor
* Create a new <code>TilemapLayer</code>.
*
* @param parent {Tilemap} The tilemap that contains this layer.
* @param id {number} The ID of this layer within the Tilemap array.
* @param key {string} Asset key for this map.
* @param mapFormat {number} Format of this map data, available: Tilemap.FORMAT_CSV or Tilemap.FORMAT_TILED_JSON.
* @param name {string} Name of this layer, so you can get this layer by its name.
* @param tileWidth {number} Width of tiles in this map.
* @param tileHeight {number} Height of tiles in this map.
*/
function TilemapLayer(parent, id, key, mapFormat, name, tileWidth, tileHeight) {
/**
* Controls whether update() and draw() are automatically called.
* @type {boolean}
*/
this.exists = true;
/**
* Controls whether draw() are automatically called.
* @type {boolean}
*/
this.visible = true;
/**
* How many tiles in each row.
* Read-only variable, do NOT recommend changing after the map is loaded!
* @type {number}
*/
this.widthInTiles = 0;
/**
* How many tiles in each column.
* Read-only variable, do NOT recommend changing after the map is loaded!
* @type {number}
*/
this.heightInTiles = 0;
/**
* Read-only variable, do NOT recommend changing after the map is loaded!
* @type {number}
*/
this.widthInPixels = 0;
/**
* Read-only variable, do NOT recommend changing after the map is loaded!
* @type {number}
*/
this.heightInPixels = 0;
/**
* Distance between REAL tiles to the tileset texture bound.
* @type {number}
*/
this.tileMargin = 0;
/**
* Distance between every 2 neighbor tile in the tileset texture.
* @type {number}
*/
this.tileSpacing = 0;
this.parent = parent;
this.game = parent.game;
this.ID = id;
this.name = name;
this.mapFormat = mapFormat;
this.tileWidth = tileWidth;
this.tileHeight = tileHeight;
this.boundsInTiles = new Phaser.Rectangle();
this.texture = new Phaser.Display.Texture(this);
this.transform = new Phaser.Components.TransformManager(this);
if (key !== null) {
this.texture.loadImage(key, false);
} else {
this.texture.opaque = true;
}
// Handy proxies
this.alpha = this.texture.alpha;
this.mapData = [];
this._tempTileBlock = [];
}
/**
* Set a specific tile with its x and y in tiles.
* @param x {number} X position of this tile in world coordinates.
* @param y {number} Y position of this tile in world coordinates.
* @param index {number} The index of this tile type in the core map data.
*/
TilemapLayer.prototype.putTileWorldXY = function (x, y, index) {
x = this.game.math.snapToFloor(x, this.tileWidth) / this.tileWidth;
y = this.game.math.snapToFloor(y, this.tileHeight) / this.tileHeight;
if (y >= 0 && y < this.mapData.length) {
if (x >= 0 && x < this.mapData[y].length) {
this.mapData[y][x] = index;
}
}
};
/**
* Set a specific tile with its x and y in tiles.
* @param x {number} X position of this tile.
* @param y {number} Y position of this tile.
* @param index {number} The index of this tile type in the core map data.
*/
TilemapLayer.prototype.putTile = function (x, y, index) {
if (y >= 0 && y < this.mapData.length) {
if (x >= 0 && x < this.mapData[y].length) {
this.mapData[y][x] = index;
}
}
};
/**
* Swap tiles with 2 kinds of indexes.
* @param tileA {number} First tile index.
* @param tileB {number} Second tile index.
* @param [x] {number} specify a Rectangle of tiles to operate. The x position in tiles of Rectangle's left-top corner.
* @param [y] {number} specify a Rectangle of tiles to operate. The y position in tiles of Rectangle's left-top corner.
* @param [width] {number} specify a Rectangle of tiles to operate. The width in tiles.
* @param [height] {number} specify a Rectangle of tiles to operate. The height in tiles.
*/
TilemapLayer.prototype.swapTile = function (tileA, tileB, x, y, width, height) {
if (typeof x === "undefined") { x = 0; }
if (typeof y === "undefined") { y = 0; }
if (typeof width === "undefined") { width = this.widthInTiles; }
if (typeof height === "undefined") { height = this.heightInTiles; }
this.getTempBlock(x, y, width, height);
for (var r = 0; r < this._tempTileBlock.length; r++) {
if (this._tempTileBlock[r].tile.index == tileA) {
this._tempTileBlock[r].newIndex = true;
}
if (this._tempTileBlock[r].tile.index == tileB) {
this.mapData[this._tempTileBlock[r].y][this._tempTileBlock[r].x] = tileA;
}
}
for (var r = 0; r < this._tempTileBlock.length; r++) {
if (this._tempTileBlock[r].newIndex == true) {
this.mapData[this._tempTileBlock[r].y][this._tempTileBlock[r].x] = tileB;
}
}
};
/**
* Fill a tile block with a specific tile index.
* @param index {number} Index of tiles you want to fill with.
* @param [x] {number} x position (in tiles) of block's left-top corner.
* @param [y] {number} y position (in tiles) of block's left-top corner.
* @param [width] {number} width of block.
* @param [height] {number} height of block.
*/
TilemapLayer.prototype.fillTile = function (index, x, y, width, height) {
if (typeof x === "undefined") { x = 0; }
if (typeof y === "undefined") { y = 0; }
if (typeof width === "undefined") { width = this.widthInTiles; }
if (typeof height === "undefined") { height = this.heightInTiles; }
this.getTempBlock(x, y, width, height);
for (var r = 0; r < this._tempTileBlock.length; r++) {
this.mapData[this._tempTileBlock[r].y][this._tempTileBlock[r].x] = index;
}
};
/**
* Set random tiles to a specific tile block.
* @param tiles {number[]} Tiles with indexes in this array will be randomly set to the given block.
* @param [x] {number} x position (in tiles) of block's left-top corner.
* @param [y] {number} y position (in tiles) of block's left-top corner.
* @param [width] {number} width of block.
* @param [height] {number} height of block.
*/
TilemapLayer.prototype.randomiseTiles = function (tiles, x, y, width, height) {
if (typeof x === "undefined") { x = 0; }
if (typeof y === "undefined") { y = 0; }
if (typeof width === "undefined") { width = this.widthInTiles; }
if (typeof height === "undefined") { height = this.heightInTiles; }
this.getTempBlock(x, y, width, height);
for (var r = 0; r < this._tempTileBlock.length; r++) {
this.mapData[this._tempTileBlock[r].y][this._tempTileBlock[r].x] = this.game.math.getRandom(tiles);
}
};
/**
* Replace one kind of tiles to another kind.
* @param tileA {number} Index of tiles you want to replace.
* @param tileB {number} Index of tiles you want to set.
* @param [x] {number} x position (in tiles) of block's left-top corner.
* @param [y] {number} y position (in tiles) of block's left-top corner.
* @param [width] {number} width of block.
* @param [height] {number} height of block.
*/
TilemapLayer.prototype.replaceTile = function (tileA, tileB, x, y, width, height) {
if (typeof x === "undefined") { x = 0; }
if (typeof y === "undefined") { y = 0; }
if (typeof width === "undefined") { width = this.widthInTiles; }
if (typeof height === "undefined") { height = this.heightInTiles; }
this.getTempBlock(x, y, width, height);
for (var r = 0; r < this._tempTileBlock.length; r++) {
if (this._tempTileBlock[r].tile.index == tileA) {
this.mapData[this._tempTileBlock[r].y][this._tempTileBlock[r].x] = tileB;
}
}
};
/**
* Get a tile block with specific position and size.(both are in tiles)
* @param x {number} X position of block's left-top corner.
* @param y {number} Y position of block's left-top corner.
* @param width {number} Width of block.
* @param height {number} Height of block.
*/
TilemapLayer.prototype.getTileBlock = function (x, y, width, height) {
var output = [];
this.getTempBlock(x, y, width, height);
for (var r = 0; r < this._tempTileBlock.length; r++) {
output.push({ x: this._tempTileBlock[r].x, y: this._tempTileBlock[r].y, tile: this._tempTileBlock[r].tile });
}
return output;
};
/**
* Get a tile with specific position (in world coordinate). (thus you give a position of a point which is within the tile)
* @param x {number} X position of the point in target tile.
* @param x {number} Y position of the point in target tile.
*/
TilemapLayer.prototype.getTileFromWorldXY = function (x, y) {
x = this.game.math.snapToFloor(x, this.tileWidth) / this.tileWidth;
y = this.game.math.snapToFloor(y, this.tileHeight) / this.tileHeight;
return this.getTileIndex(x, y);
};
/**
* Get tiles overlaps the given object.
* @param object {GameObject} Tiles you want to get that overlaps this.
* @return {array} Array with tiles informations. (Each contains x, y and the tile.)
*/
TilemapLayer.prototype.getTileOverlaps = function (object) {
if (object.body.bounds.x < 0 || object.body.bounds.x > this.widthInPixels || object.body.bounds.y < 0 || object.body.bounds.bottom > this.heightInPixels) {
return;
}
// What tiles do we need to check against?
this._tempTileX = this.game.math.snapToFloor(object.body.bounds.x, this.tileWidth) / this.tileWidth;
this._tempTileY = this.game.math.snapToFloor(object.body.bounds.y, this.tileHeight) / this.tileHeight;
this._tempTileW = (this.game.math.snapToCeil(object.body.bounds.width, this.tileWidth) + this.tileWidth) / this.tileWidth;
this._tempTileH = (this.game.math.snapToCeil(object.body.bounds.height, this.tileHeight) + this.tileHeight) / this.tileHeight;
// Loop through the tiles we've got and check overlaps accordingly (the results are stored in this._tempTileBlock)
this._tempBlockResults = [];
this.getTempBlock(this._tempTileX, this._tempTileY, this._tempTileW, this._tempTileH, true);
/*
for (var r = 0; r < this._tempTileBlock.length; r++)
{
if (this.game.world.physics.separateTile(object, this._tempTileBlock[r].x * this.tileWidth, this._tempTileBlock[r].y * this.tileHeight, this.tileWidth, this.tileHeight, this._tempTileBlock[r].tile.mass, this._tempTileBlock[r].tile.collideLeft, this._tempTileBlock[r].tile.collideRight, this._tempTileBlock[r].tile.collideUp, this._tempTileBlock[r].tile.collideDown, this._tempTileBlock[r].tile.separateX, this._tempTileBlock[r].tile.separateY) == true)
{
this._tempBlockResults.push({ x: this._tempTileBlock[r].x, y: this._tempTileBlock[r].y, tile: this._tempTileBlock[r].tile });
}
}
*/
return this._tempBlockResults;
};
/**
* Get a tile block with its position and size. (This method does not return, it'll set result to _tempTileBlock)
* @param x {number} X position of block's left-top corner.
* @param y {number} Y position of block's left-top corner.
* @param width {number} Width of block.
* @param height {number} Height of block.
* @param collisionOnly {boolean} Whethor or not ONLY return tiles which will collide (its allowCollisions value is not Collision.NONE).
*/
TilemapLayer.prototype.getTempBlock = function (x, y, width, height, collisionOnly) {
if (typeof collisionOnly === "undefined") { collisionOnly = false; }
if (x < 0) {
x = 0;
}
if (y < 0) {
y = 0;
}
if (width > this.widthInTiles) {
width = this.widthInTiles;
}
if (height > this.heightInTiles) {
height = this.heightInTiles;
}
this._tempTileBlock = [];
for (var ty = y; ty < y + height; ty++) {
for (var tx = x; tx < x + width; tx++) {
if (collisionOnly) {
if (this.mapData[ty] && this.mapData[ty][tx] && this.parent.tiles[this.mapData[ty][tx]].allowCollisions != Phaser.Types.NONE) {
this._tempTileBlock.push({ x: tx, y: ty, tile: this.parent.tiles[this.mapData[ty][tx]] });
}
} else {
if (this.mapData[ty] && this.mapData[ty][tx]) {
this._tempTileBlock.push({ x: tx, y: ty, tile: this.parent.tiles[this.mapData[ty][tx]] });
}
}
}
}
};
/**
* Get the tile index of specific position (in tiles).
* @param x {number} X position of the tile.
* @param y {number} Y position of the tile.
* @return {number} Index of the tile at that position. Return null if there isn't a tile there.
*/
TilemapLayer.prototype.getTileIndex = function (x, y) {
if (y >= 0 && y < this.mapData.length) {
if (x >= 0 && x < this.mapData[y].length) {
return this.mapData[y][x];
}
}
return null;
};
/**
* Add a column of tiles into the layer.
* @param column {string[]/number[]} An array of tile indexes to be added.
*/
TilemapLayer.prototype.addColumn = function (column) {
var data = [];
for (var c = 0; c < column.length; c++) {
data[c] = parseInt(column[c]);
}
if (this.widthInTiles == 0) {
this.widthInTiles = data.length;
this.widthInPixels = this.widthInTiles * this.tileWidth;
}
this.mapData.push(data);
this.heightInTiles++;
this.heightInPixels += this.tileHeight;
};
/**
* Update boundsInTiles with widthInTiles and heightInTiles.
*/
TilemapLayer.prototype.updateBounds = function () {
this.boundsInTiles.setTo(0, 0, this.widthInTiles, this.heightInTiles);
};
/**
* Parse tile offsets from map data.
* @return {number} length of tileOffsets array.
*/
TilemapLayer.prototype.parseTileOffsets = function () {
this.tileOffsets = [];
var i = 0;
if (this.mapFormat == Tilemap.FORMAT_TILED_JSON) {
// For some reason Tiled counts from 1 not 0
this.tileOffsets[0] = null;
i = 1;
}
for (var ty = this.tileMargin; ty < this.texture.height; ty += (this.tileHeight + this.tileSpacing)) {
for (var tx = this.tileMargin; tx < this.texture.width; tx += (this.tileWidth + this.tileSpacing)) {
this.tileOffsets[i] = { x: tx, y: ty };
i++;
}
}
return this.tileOffsets.length;
};
return TilemapLayer;
})();
Phaser.TilemapLayer = TilemapLayer;
})(Phaser || (Phaser = {}));

View file

@ -1,6 +1,4 @@
/// <reference path="../Game.ts" />
/// <reference path="Tilemap.ts" />
/// <reference path="../gameobjects/IGameObject.ts" />
/// <reference path="../_definitions.ts" />
/**
* Phaser - TilemapLayer
@ -24,7 +22,7 @@ module Phaser {
* @param tileWidth {number} Width of tiles in this map.
* @param tileHeight {number} Height of tiles in this map.
*/
constructor(parent:Tilemap, id:number, key: string, mapFormat: number, name: string, tileWidth: number, tileHeight: number) {
constructor(parent: Phaser.Tilemap, id:number, key: string, mapFormat: number, name: string, tileWidth: number, tileHeight: number) {
this.parent = parent;
this.game = parent.game;
@ -67,13 +65,13 @@ module Phaser {
/**
* Local reference to Game.
*/
public game: Game;
public game: Phaser.Game;
/**
* The tilemap that contains this layer.
* @type {Tilemap}
*/
public parent: Tilemap;
public parent: Phaser.Tilemap;
/**
* The texture used to render the Sprite.
@ -136,7 +134,7 @@ module Phaser {
* Map bounds (width and height) in tiles not pixels.
* @type {Rectangle}
*/
public boundsInTiles: Rectangle;
public boundsInTiles: Phaser.Rectangle;
/**
* Width of each tile.
@ -368,7 +366,7 @@ module Phaser {
* @param object {GameObject} Tiles you want to get that overlaps this.
* @return {array} Array with tiles informations. (Each contains x, y and the tile.)
*/
public getTileOverlaps(object: Sprite) {
public getTileOverlaps(object: Phaser.Sprite) {
// If the object is outside of the world coordinates then abort the check (tilemap has to exist within world bounds)
if (object.body.bounds.x < 0 || object.body.bounds.x > this.widthInPixels || object.body.bounds.y < 0 || object.body.bounds.bottom > this.heightInPixels)

View file

@ -1,4 +1,4 @@
/// <reference path="../Game.ts" />
/// <reference path="../_definitions.ts" />
/**
* Phaser - TimeManager
@ -16,7 +16,7 @@ module Phaser {
*
* @param game {Phaser.Game} Current game instance.
*/
constructor(game: Game) {
constructor(game: Phaser.Game) {
this.game = game;
@ -32,7 +32,7 @@ module Phaser {
/**
* Local reference to game.
*/
public game: Game;
public game: Phaser.Game;
/**
* Time when this object created.
@ -40,13 +40,6 @@ module Phaser {
*/
private _started: number;
/**
* Time scale factor.
* Set it to 0.5 for slow motion, to 2.0 makes game twice faster.
* @type {number}
*/
//public timeScale: number = 1.0;
/**
* Elapsed since last frame.
* @type {number}

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