Skip to content

Commit f3c9049

Browse files
committed
Camera updates, scrollFix check and some new pictures and tests.
1 parent 7b4374c commit f3c9049

40 files changed

Lines changed: 342 additions & 197 deletions

Docs/phaser_scrollfactor.png

98.6 KB
Loading

Phaser/cameras/Camera.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ module Phaser {
523523

524524
if (this.bounds)
525525
{
526-
this._game.stage.context.fillText('Bounds: ' + this.bounds.width + ' x ' + this.bounds.height, x, y + 56);
526+
this._game.stage.context.fillText('Bounds: ' + this.bounds.width + ' x ' + this.bounds.height, x, y + 42);
527527
}
528528

529529
}

Phaser/gameobjects/Sprite.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ module Phaser {
4848
this.height = this.frameBounds.height;
4949

5050
// Transform related (if we add any more then move to a component)
51-
this.origin = new Phaser.Vec2(this.width / 2, this.height / 2);
51+
this.origin = new Phaser.Vec2(0, 0);
5252
this.scale = new Phaser.Vec2(1, 1);
5353
this.skew = new Phaser.Vec2(0, 0);
5454

Phaser/renderers/CanvasRenderer.ts

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ module Phaser {
7878
this._fy = sprite.scale.y;
7979
this._sin = 0;
8080
this._cos = 1;
81+
this._dx = (camera.scaledX * sprite.scrollFactor.x) + sprite.frameBounds.x - (camera.worldView.x * sprite.scrollFactor.x);
82+
this._dy = (camera.scaledY * sprite.scrollFactor.y) + sprite.frameBounds.y - (camera.worldView.y * sprite.scrollFactor.y);
83+
this._dw = sprite.frameBounds.width;
84+
this._dh = sprite.frameBounds.height;
8185

8286
// Alpha
8387
if (sprite.texture.alpha !== 1)
@@ -98,11 +102,6 @@ module Phaser {
98102
this._fy = -sprite.scale.y;
99103
}
100104

101-
this._dx = (camera.scaledX * sprite.scrollFactor.x) + sprite.frameBounds.x - (camera.worldView.x * sprite.scrollFactor.x);
102-
this._dy = (camera.scaledY * sprite.scrollFactor.y) + sprite.frameBounds.y - (camera.worldView.y * sprite.scrollFactor.y);
103-
this._dw = sprite.frameBounds.width;
104-
this._dh = sprite.frameBounds.height;
105-
106105
if (sprite.animations.currentFrame !== null)
107106
{
108107
this._sx = sprite.animations.currentFrame.x;
@@ -115,15 +114,6 @@ module Phaser {
115114
}
116115
}
117116

118-
// Apply camera difference - looks like this is already applied?
119-
/*
120-
if (sprite.scrollFactor.x !== 1 || sprite.scrollFactor.y !== 1)
121-
{
122-
//this._dx -= (camera.worldView.x * this.scrollFactor.x);
123-
//this._dy -= (camera.worldView.y * this.scrollFactor.y);
124-
}
125-
*/
126-
127117
// Rotation and Flipped
128118
if (sprite.modified)
129119
{
@@ -149,10 +139,11 @@ module Phaser {
149139
}
150140
else
151141
{
152-
this._dx -= sprite.origin.x;
153-
this._dy -= sprite.origin.y;
154-
//this._dw = sprite.frameBounds.width * sprite.scale.x;
155-
//this._dh = sprite.frameBounds.height * sprite.scale.y;
142+
if (!sprite.origin.equals(0))
143+
{
144+
this._dx -= sprite.origin.x;
145+
this._dy -= sprite.origin.y;
146+
}
156147
}
157148

158149
this._sx = Math.round(this._sx);

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ TODO:
2626
* Removed ignoreGlobalUpdate because it checks exists etc in the Group update, so remove those checks from Sprite.update (same for render)
2727
* Investigate why tweens don't restart after the game pauses
2828
* Fix bug in Tween yoyo + loop combo
29+
* Copy the setTransform from Sprite to Camera
30+
* Move Camera.scroll.x to just Camera.x/y
31+
32+
2933

3034
V1.0.0
3135

@@ -41,7 +45,6 @@ V1.0.0
4145
* Refactored QuadTree so it no longer creates any temporary variables in any methods.
4246
* The Sprite Renderer now uses a single setTransform for scale, rotation and translation that respects the Sprite.origin value in all cases.
4347
* Sprite.modified is set to true if scale, rotation, skew or flip have been used.
44-
* By default the Sprite.origin is set to the center of the sprite, but can be offset to anywhere.
4548
* Added Tween.loop property so they can now re-run themselves indefinitely.
4649
* Added Tween.yoyo property so they can reverse themselves after completing.
4750

Tests/Tests.csproj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,18 @@
5353
<TypeScriptSourceMap>false</TypeScriptSourceMap>
5454
</PropertyGroup>
5555
<ItemGroup>
56+
<TypeScriptCompile Include="cameras\basic camera 1.ts" />
57+
<Content Include="cameras\basic camera 1.js">
58+
<DependentUpon>basic camera 1.ts</DependentUpon>
59+
</Content>
60+
<TypeScriptCompile Include="cameras\scrollfactor 1.ts" />
61+
<Content Include="cameras\scrollfactor 1.js">
62+
<DependentUpon>scrollfactor 1.ts</DependentUpon>
63+
</Content>
64+
<TypeScriptCompile Include="cameras\scrollfactor 2.ts" />
65+
<Content Include="cameras\scrollfactor 2.js">
66+
<DependentUpon>scrollfactor 2.ts</DependentUpon>
67+
</Content>
5668
<Content Include="tweens\tween loop 1.js">
5769
<DependentUpon>tween loop 1.ts</DependentUpon>
5870
</Content>

Tests/assets/pics/WARZONE.png

77.6 KB
Loading
27.6 KB
Loading
7.99 KB
Loading
50.3 KB
Loading

0 commit comments

Comments
 (0)