Skip to content

Commit 09f57fa

Browse files
committed
Preparing new tests
1 parent 3c0c349 commit 09f57fa

237 files changed

Lines changed: 19236 additions & 40298 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Phaser/Phaser.csproj

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -92,21 +92,20 @@
9292
<DependentUpon>Game.ts</DependentUpon>
9393
</Content>
9494
<TypeScriptCompile Include="gameobjects\Sprite.ts" />
95+
<TypeScriptCompile Include="gameobjects\IGameObject.ts" />
96+
<Content Include="gameobjects\IGameObject.js">
97+
<DependentUpon>IGameObject.ts</DependentUpon>
98+
</Content>
9599
<Content Include="math\GameMath.js">
96100
<DependentUpon>GameMath.ts</DependentUpon>
97101
</Content>
98102
<TypeScriptCompile Include="gameobjects\GameObjectFactory.ts" />
99103
<Content Include="gameobjects\GameObjectFactory.js">
100104
<DependentUpon>GameObjectFactory.ts</DependentUpon>
101105
</Content>
102-
<TypeScriptCompile Include="components\ScrollRegion.ts" />
103-
<Content Include="components\ScrollRegion.js">
104-
<DependentUpon>ScrollRegion.ts</DependentUpon>
105-
</Content>
106106
<Content Include="gameobjects\Sprite.js">
107107
<DependentUpon>Sprite.ts</DependentUpon>
108108
</Content>
109-
<TypeScriptCompile Include="geom\Polygon.ts" />
110109
<TypeScriptCompile Include="utils\PointUtils.ts" />
111110
<TypeScriptCompile Include="utils\CircleUtils.ts" />
112111
<TypeScriptCompile Include="renderers\CanvasRenderer.ts" />
@@ -131,24 +130,17 @@
131130
<Content Include="utils\PointUtils.js">
132131
<DependentUpon>PointUtils.ts</DependentUpon>
133132
</Content>
134-
<Content Include="geom\Polygon.js">
135-
<DependentUpon>Polygon.ts</DependentUpon>
136-
</Content>
137-
<TypeScriptCompile Include="geom\Response.ts" />
138133
<TypeScriptCompile Include="utils\RectangleUtils.ts" />
139134
<Content Include="utils\RectangleUtils.js">
140135
<DependentUpon>RectangleUtils.ts</DependentUpon>
141136
</Content>
142-
<Content Include="geom\Response.js">
143-
<DependentUpon>Response.ts</DependentUpon>
144-
</Content>
145137
<Content Include="core\Circle.js">
146138
<DependentUpon>Circle.ts</DependentUpon>
147139
</Content>
148-
<Content Include="geom\IntersectResult.js">
140+
<Content Include="math\IntersectResult.js">
149141
<DependentUpon>IntersectResult.ts</DependentUpon>
150142
</Content>
151-
<Content Include="geom\Line.js">
143+
<Content Include="core\Line.js">
152144
<DependentUpon>Line.ts</DependentUpon>
153145
</Content>
154146
<TypeScriptCompile Include="math\Vec2Utils.ts" />
@@ -216,18 +208,10 @@
216208
<Content Include="system\StageScaleMode.js">
217209
<DependentUpon>StageScaleMode.ts</DependentUpon>
218210
</Content>
219-
<Content Include="components\Tile.js">
220-
<DependentUpon>Tile.ts</DependentUpon>
221-
</Content>
222-
<TypeScriptCompile Include="components\TilemapLayer.ts" />
223-
<Content Include="components\TilemapLayer.js">
224-
<DependentUpon>TilemapLayer.ts</DependentUpon>
225-
</Content>
226211
<Content Include="tweens\Tween.js">
227212
<DependentUpon>Tween.ts</DependentUpon>
228213
</Content>
229214
<TypeScriptCompile Include="tweens\Tween.ts" />
230-
<TypeScriptCompile Include="components\Tile.ts" />
231215
<TypeScriptCompile Include="system\StageScaleMode.ts" />
232216
<TypeScriptCompile Include="system\RequestAnimationFrame.ts" />
233217
<TypeScriptCompile Include="math\RandomDataGenerator.ts" />
@@ -299,8 +283,8 @@
299283
<TypeScriptCompile Include="components\animation\Frame.ts" />
300284
<TypeScriptCompile Include="loader\AnimationLoader.ts" />
301285
<TypeScriptCompile Include="components\animation\Animation.ts" />
302-
<TypeScriptCompile Include="geom\Line.ts" />
303-
<TypeScriptCompile Include="geom\IntersectResult.ts" />
286+
<TypeScriptCompile Include="core\Line.ts" />
287+
<TypeScriptCompile Include="math\IntersectResult.ts" />
304288
<TypeScriptCompile Include="core\Circle.ts" />
305289
<Content Include="core\Group.js">
306290
<DependentUpon>Group.ts</DependentUpon>

Phaser/State.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ module Phaser {
2121
this.add = game.add;
2222
this.camera = game.camera;
2323
this.cache = game.cache;
24-
this.collision = game.collision;
24+
//this.collision = game.collision;
2525
this.input = game.input;
2626
this.loader = game.loader;
2727
this.math = game.math;
28-
this.motion = game.motion;
28+
//this.motion = game.motion;
2929
this.sound = game.sound;
3030
this.stage = game.stage;
3131
this.time = game.time;
@@ -55,7 +55,7 @@ module Phaser {
5555
* Reference to the collision helper.
5656
* @type {Collision}
5757
*/
58-
public collision: Collision;
58+
//public collision: Collision;
5959

6060
/**
6161
* Reference to the GameObject Factory.
@@ -85,7 +85,7 @@ module Phaser {
8585
* Reference to the motion helper.
8686
* @type {Motion}
8787
*/
88-
public motion: Motion;
88+
//public motion: Motion;
8989

9090
/**
9191
* Reference to the sound manager.
@@ -161,9 +161,9 @@ module Phaser {
161161
* @param context The context in which the callbacks will be called
162162
* @returns {boolean} true if the objects overlap, otherwise false.
163163
*/
164-
public collide(objectOrGroup1 = null, objectOrGroup2 = null, notifyCallback = null, context? = this.game.callbackContext): bool {
165-
return this.collision.overlap(objectOrGroup1, objectOrGroup2, notifyCallback, Collision.separate, context);
166-
}
164+
//public collide(objectOrGroup1 = null, objectOrGroup2 = null, notifyCallback = null, context? = this.game.callbackContext): bool {
165+
// return this.collision.overlap(objectOrGroup1, objectOrGroup2, notifyCallback, Collision.separate, context);
166+
//}
167167

168168
}
169169

Phaser/components/TilemapLayer.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
/// <reference path="../Game.ts" />
2+
/// <reference path="../gameobjects/Tilemap.ts" />
3+
/// <reference path="../gameobjects/IGameObject.ts" />
24

35
/**
46
* Phaser - TilemapLayer
@@ -354,7 +356,7 @@ module Phaser {
354356
* @param object {GameObject} Tiles you want to get that overlaps this.
355357
* @return {array} Array with tiles informations. (Each contains x, y and the tile.)
356358
*/
357-
public getTileOverlaps(object: GameObject) {
359+
public getTileOverlaps(object: IGameObject) {
358360

359361
// If the object is outside of the world coordinates then abort the check (tilemap has to exist within world bounds)
360362
if (object.collisionMask.x < 0 || object.collisionMask.x > this.widthInPixels || object.collisionMask.y < 0 || object.collisionMask.bottom > this.heightInPixels)

Phaser/components/sprite/Texture.ts

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ module Phaser.Components {
1414

1515
constructor(parent: Sprite, key?: string = '', canvas?: HTMLCanvasElement = null, context?: CanvasRenderingContext2D = null) {
1616

17+
this._game = parent.game;
1718
this._sprite = parent;
1819

1920
this.canvas = canvas;
@@ -30,6 +31,11 @@ module Phaser.Components {
3031

3132
}
3233

34+
/**
35+
*
36+
*/
37+
private _game: Game;
38+
3339
/**
3440
* Reference to the Image stored in the Game.Cache that is used as the texture for the Sprite.
3541
*/
@@ -121,17 +127,50 @@ module Phaser.Components {
121127
* @param clearAnimations {boolean} If this Sprite has a set of animation data already loaded you can choose to keep or clear it with this boolean
122128
* @return {Sprite} Sprite instance itself.
123129
*/
124-
public loadImage(key: string, clearAnimations: bool = true): Sprite {
125-
return Phaser.SpriteUtils.loadTexture(this._sprite, key, clearAnimations);
130+
public loadImage(key: string, clearAnimations: bool = true) {
131+
132+
//if (clearAnimations && sprite.animations.frameData !== null)
133+
//{
134+
// sprite.animations.destroy();
135+
//}
136+
137+
if (this._game.cache.getImage(key) !== null)
138+
{
139+
this.setTo(this._game.cache.getImage(key), null);
140+
141+
if (this._game.cache.isSpriteSheet(key))
142+
{
143+
//sprite.animations.loadFrameData(sprite._game.cache.getFrameData(key));
144+
//sprite.collisionMask.width = sprite.animations.currentFrame.width;
145+
//sprite.collisionMask.height = sprite.animations.currentFrame.height;
146+
}
147+
else
148+
{
149+
this._sprite.frameBounds.width = this.width;
150+
this._sprite.frameBounds.height = this.height;
151+
//sprite.collisionMask.width = sprite._texture.width;
152+
//sprite.collisionMask.height = sprite._texture.height;
153+
}
154+
}
155+
126156
}
127157

128158
/**
129159
* Load a DynamicTexture as its texture.
130160
* @param texture {DynamicTexture} The texture object to be used by this sprite.
131161
* @return {Sprite} Sprite instance itself.
132162
*/
133-
public loadDynamicTexture(texture: DynamicTexture): Sprite {
134-
return Phaser.SpriteUtils.loadDynamicTexture(this._sprite, texture);
163+
public loadDynamicTexture(texture: DynamicTexture) {
164+
165+
//if (sprite.animations.frameData !== null)
166+
//{
167+
// sprite.animations.destroy();
168+
//}
169+
170+
this.setTo(null, texture);
171+
this._sprite.frameBounds.width = this.width;
172+
this._sprite.frameBounds.height = this.height;
173+
135174
}
136175

137176
/**
File renamed without changes.

Phaser/gameobjects/DynamicTexture.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
/// <reference path="../Game.ts" />
2+
/// <reference path="../utils/RectangleUtils.ts" />
3+
/// <reference path="IGameObject.ts" />
24

35
/**
46
* Phaser - DynamicTexture
@@ -234,7 +236,7 @@ module Phaser {
234236
public copyPixels(sourceTexture: DynamicTexture, sourceRect: Rectangle, destPoint: Point) {
235237

236238
// Swap for drawImage if the sourceRect is the same size as the sourceTexture to avoid a costly getImageData call
237-
if (sourceRect.equals(this.bounds) == true)
239+
if (Phaser.RectangleUtils.equals(sourceRect, this.bounds) == true)
238240
{
239241
this.context.drawImage(sourceTexture.canvas, destPoint.x, destPoint.y);
240242
}
@@ -246,15 +248,15 @@ module Phaser {
246248
}
247249

248250
/**
249-
* Given an array of GameObjects it will update each of them so that their canvas/contexts reference this DynamicTexture
251+
* Given an array of Sprites it will update each of them so that their canvas/contexts reference this DynamicTexture
250252
* @param objects {Array} An array of GameObjects, or objects that inherit from it such as Sprites
251253
*/
252-
public assignCanvasToGameObjects(objects: GameObject[]) {
254+
public assignCanvasToGameObjects(objects: IGameObject[]) {
253255

254256
for (var i = 0; i < objects.length; i++)
255257
{
256-
objects[i].canvas = this.canvas;
257-
objects[i].context = this.context;
258+
objects[i].texture.canvas = this.canvas;
259+
objects[i].texture.context = this.context;
258260
}
259261

260262
}
@@ -275,9 +277,7 @@ module Phaser {
275277
* @param y {number} The Y coordinate to render on the stage to (given in screen coordinates, not world)
276278
*/
277279
public render(x?: number = 0, y?: number = 0) {
278-
279280
this.game.stage.context.drawImage(this.canvas, x, y);
280-
281281
}
282282

283283
public get width(): number {

Phaser/gameobjects/GameObjectFactory.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,9 @@ module Phaser {
135135
* @param [tileHeight] {number} height of each tile.
136136
* @return {Tilemap} The newly created tilemap object.
137137
*/
138-
public tilemap(key: string, mapData: string, format: number, resizeWorld: bool = true, tileWidth?: number = 0, tileHeight?: number = 0): Tilemap {
139-
return <Tilemap> this._world.group.add(new Tilemap(this._game, key, mapData, format, resizeWorld, tileWidth, tileHeight));
140-
}
138+
//public tilemap(key: string, mapData: string, format: number, resizeWorld: bool = true, tileWidth?: number = 0, tileHeight?: number = 0): Tilemap {
139+
// return <Tilemap> this._world.group.add(new Tilemap(this._game, key, mapData, format, resizeWorld, tileWidth, tileHeight));
140+
//}
141141

142142
/**
143143
* Create a tween object for a specific object.
@@ -200,9 +200,9 @@ module Phaser {
200200
* @param tilemap The Tilemap to add to the Game World
201201
* @return {Phaser.Tilemap} The Tilemap object
202202
*/
203-
public existingTilemap(tilemap: Tilemap): Tilemap {
204-
return this._world.group.add(tilemap);
205-
}
203+
//public existingTilemap(tilemap: Tilemap): Tilemap {
204+
// return this._world.group.add(tilemap);
205+
//}
206206

207207
/**
208208
* Add an existing Tween to the current world.

Phaser/gameobjects/IGameObject.ts

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/// <reference path="../Game.ts" />
2+
3+
module Phaser {
4+
5+
export interface IGameObject {
6+
7+
/**
8+
* Reference to the main game object
9+
*/
10+
game: Game;
11+
12+
/**
13+
* The type of game object.
14+
*/
15+
type: number;
16+
17+
/**
18+
* Reference to the Renderer.renderSprite method. Can be overriden by custom classes.
19+
*/
20+
render;
21+
22+
/**
23+
* Controls if both <code>update</code> and render are called by the core game loop.
24+
*/
25+
exists: bool;
26+
27+
/**
28+
* Controls if <code>update()</code> is automatically called by the core game loop.
29+
*/
30+
active: bool;
31+
32+
/**
33+
* Controls if this Sprite is rendered or skipped during the core game loop.
34+
*/
35+
visible: bool;
36+
37+
/**
38+
* The position of the Sprite in world and screen coordinates.
39+
*/
40+
position: Phaser.Components.Position;
41+
42+
/**
43+
* The texture used to render the Sprite.
44+
*/
45+
texture: Phaser.Components.Texture;
46+
47+
/**
48+
* Scale of the Sprite. A scale of 1.0 is the original size. 0.5 half size. 2.0 double sized.
49+
*/
50+
scale: Phaser.Vec2;
51+
52+
/**
53+
* The influence of camera movement upon the Sprite.
54+
*/
55+
scrollFactor: Phaser.Vec2;
56+
57+
}
58+
59+
}

0 commit comments

Comments
 (0)