Skip to content

Commit ce15235

Browse files
committed
ScrollZone back in under the new renderer with new demos
1 parent f2054f8 commit ce15235

28 files changed

Lines changed: 1582 additions & 349 deletions

Phaser/Phaser.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
<Content Include="components\camera\CameraFX.js">
7070
<DependentUpon>CameraFX.ts</DependentUpon>
7171
</Content>
72+
<TypeScriptCompile Include="components\ScrollRegion.ts" />
7273
<Content Include="components\sprite\Texture.js">
7374
<DependentUpon>Texture.ts</DependentUpon>
7475
</Content>
@@ -93,6 +94,7 @@
9394
<Content Include="gameobjects\IGameObject.js">
9495
<DependentUpon>IGameObject.ts</DependentUpon>
9596
</Content>
97+
<TypeScriptCompile Include="gameobjects\ScrollZone.ts" />
9698
<Content Include="math\GameMath.js">
9799
<DependentUpon>GameMath.ts</DependentUpon>
98100
</Content>

Phaser/components/sprite/Physics.ts

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
/// <reference path="../../core/Vec2.ts" />
22
/// <reference path="../../core/Point.ts" />
3+
/// <reference path="../../math/Vec2Utils.ts" />
34
/// <reference path="../../physics/AABB.ts" />
45

56
/**
67
* Phaser - Components - Physics
7-
*
8-
*
98
*/
109

1110
module Phaser.Components {
@@ -14,32 +13,24 @@ module Phaser.Components {
1413

1514
constructor(parent: Sprite) {
1615

17-
this._game = parent.game;
16+
this.game = parent.game;
1817
this._sprite = parent;
1918

20-
// Copy from PhysicsManager?
21-
this.gravity = new Vec2;
22-
this.drag = new Vec2;
23-
this.bounce = new Vec2;
24-
this.friction = new Vec2;
19+
this.gravity = Vec2Utils.clone(this.game.world.physics.gravity);
20+
this.drag = Vec2Utils.clone(this.game.world.physics.drag);
21+
this.bounce = Vec2Utils.clone(this.game.world.physics.bounce);
22+
this.friction = Vec2Utils.clone(this.game.world.physics.friction);
23+
2524
this.velocity = new Vec2;
2625
this.acceleration = new Vec2;
2726

28-
//this.AABB = new Phaser.Physics.AABB(this._game, this._sprite, this._sprite.x, this._sprite.y, this._sprite.width, this._sprite.height);
29-
this.shape = this._game.world.physics.add(new Phaser.Physics.AABB(this._game, this._sprite, this._sprite.x, this._sprite.y, this._sprite.width, this._sprite.height));
27+
this.shape = this.game.world.physics.add(new Phaser.Physics.AABB(this.game, this._sprite, this._sprite.x, this._sprite.y, this._sprite.width, this._sprite.height));
3028

3129
}
3230

33-
/**
34-
*
35-
*/
36-
private _game: Game;
37-
38-
/**
39-
*
40-
*/
4131
private _sprite: Sprite;
4232

33+
public game: Game;
4334
public shape: Phaser.Physics.IPhysicsShape;
4435

4536
/**
@@ -70,10 +61,6 @@ module Phaser.Components {
7061
{
7162
this._sprite.x = (this.shape.position.x - this.shape.bounds.halfWidth) - this.shape.offset.x;
7263
this._sprite.y = (this.shape.position.y - this.shape.bounds.halfHeight) - this.shape.offset.y;
73-
//this._sprite.x = (this.shape.position.x - this.shape.bounds.halfWidth);
74-
//this._sprite.y = (this.shape.position.y - this.shape.bounds.halfHeight);
75-
//this._sprite.x = (this.shape.position.x);
76-
//this._sprite.y = (this.shape.position.y);
7764
}
7865
}
7966

Phaser/components/sprite/Texture.ts

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ module Phaser.Components {
4444
/**
4545
* Reference to the Image stored in the Game.Cache that is used as the texture for the Sprite.
4646
*/
47-
private _imageTexture = null;
47+
public imageTexture = null;
4848

4949
/**
5050
* Reference to the DynamicTexture that is used as the texture for the Sprite.
5151
* @type {DynamicTexture}
5252
*/
53-
private _dynamicTexture: DynamicTexture = null;
53+
public dynamicTexture: DynamicTexture = null;
5454

5555
/**
5656
* The status of the texture image.
@@ -105,6 +105,12 @@ module Phaser.Components {
105105
*/
106106
public flippedY: bool = false;
107107

108+
/**
109+
* Is the texture a DynamicTexture?
110+
* @type {boolean}
111+
*/
112+
public isDynamic: bool = false;
113+
108114
/**
109115
* Updates the texture being used to render the Sprite.
110116
* Called automatically by SpriteUtils.loadTexture and SpriteUtils.loadDynamicTexture.
@@ -113,13 +119,15 @@ module Phaser.Components {
113119

114120
if (dynamic)
115121
{
116-
this._dynamicTexture = dynamic;
117-
this.texture = this._dynamicTexture.canvas;
122+
this.isDynamic = true;
123+
this.dynamicTexture = dynamic;
124+
this.texture = this.dynamicTexture.canvas;
118125
}
119126
else
120127
{
121-
this._imageTexture = image;
122-
this.texture = this._imageTexture;
128+
this.isDynamic = false;
129+
this.imageTexture = image;
130+
this.texture = this.imageTexture;
123131
}
124132

125133
this.loaded = true;
@@ -183,13 +191,13 @@ module Phaser.Components {
183191
*/
184192
public get width(): number {
185193

186-
if (this._dynamicTexture)
194+
if (this.isDynamic)
187195
{
188-
return this._dynamicTexture.width;
196+
return this.dynamicTexture.width;
189197
}
190198
else
191199
{
192-
return this._imageTexture.width;
200+
return this.imageTexture.width;
193201
}
194202
}
195203

@@ -199,13 +207,13 @@ module Phaser.Components {
199207
*/
200208
public get height(): number {
201209

202-
if (this._dynamicTexture)
210+
if (this.isDynamic)
203211
{
204-
return this._dynamicTexture.height;
212+
return this.dynamicTexture.height;
205213
}
206214
else
207215
{
208-
return this._imageTexture.height;
216+
return this.imageTexture.height;
209217
}
210218

211219
}

Phaser/gameobjects/GameObjectFactory.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ module Phaser {
134134
* @param height {number} Height of this object.
135135
* @returns {ScrollZone} The newly created scroll zone object.
136136
*/
137-
//public scrollZone(key: string, x?: number = 0, y?: number = 0, width?: number = 0, height?: number = 0): ScrollZone {
138-
// return <ScrollZone> this._world.group.add(new ScrollZone(this._game, key, x, y, width, height));
139-
//}
137+
public scrollZone(key: string, x?: number = 0, y?: number = 0, width?: number = 0, height?: number = 0): ScrollZone {
138+
return <ScrollZone> this._world.group.add(new ScrollZone(this._game, key, x, y, width, height));
139+
}
140140

141141
/**
142142
* Create a new Tilemap.
@@ -203,9 +203,9 @@ module Phaser {
203203
* @param scrollZone The ScrollZone to add to the Game World
204204
* @return {Phaser.ScrollZone} The ScrollZone object
205205
*/
206-
//public existingScrollZone(scrollZone: ScrollZone): ScrollZone {
207-
// return this._world.group.add(scrollZone);
208-
//}
206+
public existingScrollZone(scrollZone: ScrollZone): ScrollZone {
207+
return this._world.group.add(scrollZone);
208+
}
209209

210210
/**
211211
* Add an existing Tilemap to the current world.

0 commit comments

Comments
 (0)