Camera updates, scrollFix check and some new pictures and tests.

This commit is contained in:
Richard Davey
2013-05-29 17:31:57 +01:00
parent 7b4374cabf
commit f3c9049e76
40 changed files with 342 additions and 197 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 99 KiB

+1 -1
View File
@@ -523,7 +523,7 @@ module Phaser {
if (this.bounds)
{
this._game.stage.context.fillText('Bounds: ' + this.bounds.width + ' x ' + this.bounds.height, x, y + 56);
this._game.stage.context.fillText('Bounds: ' + this.bounds.width + ' x ' + this.bounds.height, x, y + 42);
}
}
+1 -1
View File
@@ -48,7 +48,7 @@ module Phaser {
this.height = this.frameBounds.height;
// Transform related (if we add any more then move to a component)
this.origin = new Phaser.Vec2(this.width / 2, this.height / 2);
this.origin = new Phaser.Vec2(0, 0);
this.scale = new Phaser.Vec2(1, 1);
this.skew = new Phaser.Vec2(0, 0);
+9 -18
View File
@@ -78,6 +78,10 @@ module Phaser {
this._fy = sprite.scale.y;
this._sin = 0;
this._cos = 1;
this._dx = (camera.scaledX * sprite.scrollFactor.x) + sprite.frameBounds.x - (camera.worldView.x * sprite.scrollFactor.x);
this._dy = (camera.scaledY * sprite.scrollFactor.y) + sprite.frameBounds.y - (camera.worldView.y * sprite.scrollFactor.y);
this._dw = sprite.frameBounds.width;
this._dh = sprite.frameBounds.height;
// Alpha
if (sprite.texture.alpha !== 1)
@@ -98,11 +102,6 @@ module Phaser {
this._fy = -sprite.scale.y;
}
this._dx = (camera.scaledX * sprite.scrollFactor.x) + sprite.frameBounds.x - (camera.worldView.x * sprite.scrollFactor.x);
this._dy = (camera.scaledY * sprite.scrollFactor.y) + sprite.frameBounds.y - (camera.worldView.y * sprite.scrollFactor.y);
this._dw = sprite.frameBounds.width;
this._dh = sprite.frameBounds.height;
if (sprite.animations.currentFrame !== null)
{
this._sx = sprite.animations.currentFrame.x;
@@ -115,15 +114,6 @@ module Phaser {
}
}
// Apply camera difference - looks like this is already applied?
/*
if (sprite.scrollFactor.x !== 1 || sprite.scrollFactor.y !== 1)
{
//this._dx -= (camera.worldView.x * this.scrollFactor.x);
//this._dy -= (camera.worldView.y * this.scrollFactor.y);
}
*/
// Rotation and Flipped
if (sprite.modified)
{
@@ -149,10 +139,11 @@ module Phaser {
}
else
{
this._dx -= sprite.origin.x;
this._dy -= sprite.origin.y;
//this._dw = sprite.frameBounds.width * sprite.scale.x;
//this._dh = sprite.frameBounds.height * sprite.scale.y;
if (!sprite.origin.equals(0))
{
this._dx -= sprite.origin.x;
this._dy -= sprite.origin.y;
}
}
this._sx = Math.round(this._sx);
+4 -1
View File
@@ -26,6 +26,10 @@ TODO:
* Removed ignoreGlobalUpdate because it checks exists etc in the Group update, so remove those checks from Sprite.update (same for render)
* Investigate why tweens don't restart after the game pauses
* Fix bug in Tween yoyo + loop combo
* Copy the setTransform from Sprite to Camera
* Move Camera.scroll.x to just Camera.x/y
V1.0.0
@@ -41,7 +45,6 @@ V1.0.0
* Refactored QuadTree so it no longer creates any temporary variables in any methods.
* The Sprite Renderer now uses a single setTransform for scale, rotation and translation that respects the Sprite.origin value in all cases.
* Sprite.modified is set to true if scale, rotation, skew or flip have been used.
* By default the Sprite.origin is set to the center of the sprite, but can be offset to anywhere.
* Added Tween.loop property so they can now re-run themselves indefinitely.
* Added Tween.yoyo property so they can reverse themselves after completing.
+12
View File
@@ -53,6 +53,18 @@
<TypeScriptSourceMap>false</TypeScriptSourceMap>
</PropertyGroup>
<ItemGroup>
<TypeScriptCompile Include="cameras\basic camera 1.ts" />
<Content Include="cameras\basic camera 1.js">
<DependentUpon>basic camera 1.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="cameras\scrollfactor 1.ts" />
<Content Include="cameras\scrollfactor 1.js">
<DependentUpon>scrollfactor 1.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="cameras\scrollfactor 2.ts" />
<Content Include="cameras\scrollfactor 2.js">
<DependentUpon>scrollfactor 2.ts</DependentUpon>
</Content>
<Content Include="tweens\tween loop 1.js">
<DependentUpon>tween loop 1.ts</DependentUpon>
</Content>
Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

+31
View File
@@ -0,0 +1,31 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
function init() {
game.world.setSize(1920, 1200, true);
game.loader.addImageFile('backdrop', 'assets/pics/remember-me.jpg');
game.loader.addImageFile('melon', 'assets/sprites/melon.png');
game.loader.load();
}
function create() {
game.add.sprite(0, 0, 'backdrop');
for(var i = 0; i < 100; i++) {
game.add.sprite(game.world.randomX, game.world.randomY, 'melon');
}
}
function update() {
if(game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
game.camera.scroll.x -= 4;
} else if(game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
game.camera.scroll.x += 4;
}
if(game.input.keyboard.isDown(Phaser.Keyboard.UP)) {
game.camera.scroll.y -= 4;
} else if(game.input.keyboard.isDown(Phaser.Keyboard.DOWN)) {
game.camera.scroll.y += 4;
}
}
function render() {
game.camera.renderDebugInfo(32, 32);
}
})();
+57
View File
@@ -0,0 +1,57 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
function init() {
game.world.setSize(1920, 1200, true);
game.loader.addImageFile('backdrop', 'assets/pics/remember-me.jpg');
game.loader.addImageFile('melon', 'assets/sprites/melon.png');
game.loader.load();
}
function create() {
game.add.sprite(0, 0, 'backdrop');
for (var i = 0; i < 100; i++)
{
game.add.sprite(game.world.randomX, game.world.randomY, 'melon');
}
}
function update() {
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
{
game.camera.scroll.x -= 4;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
{
game.camera.scroll.x += 4;
}
if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
{
game.camera.scroll.y -= 4;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
{
game.camera.scroll.y += 4;
}
}
function render() {
game.camera.renderDebugInfo(32, 32);
}
})();
+32
View File
@@ -0,0 +1,32 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
function init() {
game.world.setSize(1920, 1200, true);
game.loader.addImageFile('backdrop', 'assets/pics/remember-me.jpg');
game.loader.addImageFile('ball', 'assets/sprites/shinyball.png');
game.loader.load();
}
function create() {
game.add.sprite(0, 0, 'backdrop');
for(var i = 0; i < 400; i++) {
var tempBall = game.add.sprite(game.world.randomX * 2, game.world.randomY * 2, 'ball');
tempBall.scrollFactor.setTo(2, 2);
}
}
function update() {
if(game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
game.camera.scroll.x -= 4;
} else if(game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
game.camera.scroll.x += 4;
}
if(game.input.keyboard.isDown(Phaser.Keyboard.UP)) {
game.camera.scroll.y -= 4;
} else if(game.input.keyboard.isDown(Phaser.Keyboard.DOWN)) {
game.camera.scroll.y += 4;
}
}
function render() {
game.camera.renderDebugInfo(32, 32);
}
})();
+58
View File
@@ -0,0 +1,58 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
function init() {
game.world.setSize(1920, 1200, true);
game.loader.addImageFile('backdrop', 'assets/pics/remember-me.jpg');
game.loader.addImageFile('ball', 'assets/sprites/shinyball.png');
game.loader.load();
}
function create() {
game.add.sprite(0, 0, 'backdrop');
for (var i = 0; i < 400; i++)
{
var tempBall:Phaser.Sprite = game.add.sprite(game.world.randomX * 2, game.world.randomY * 2, 'ball');
tempBall.scrollFactor.setTo(2, 2);
}
}
function update() {
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
{
game.camera.scroll.x -= 4;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
{
game.camera.scroll.x += 4;
}
if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
{
game.camera.scroll.y -= 4;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
{
game.camera.scroll.y += 4;
}
}
function render() {
game.camera.renderDebugInfo(32, 32);
}
})();
+31
View File
@@ -0,0 +1,31 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
function init() {
game.world.setSize(1600, 800, true);
game.loader.addImageFile('disk', 'assets/pics/devilstar_demo_download_disk.png');
game.loader.load();
}
function create() {
for(var i = 0; i < 10; i++) {
var temp = game.add.sprite(600 + (10 * i), 200 + (10 * i), 'disk');
temp.scrollFactor.setTo(i / 2, i / 2);
}
//game.camera.focusOnXY(800, 200);
}
function update() {
if(game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
game.camera.scroll.x -= 4;
} else if(game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
game.camera.scroll.x += 4;
}
if(game.input.keyboard.isDown(Phaser.Keyboard.UP)) {
game.camera.scroll.y -= 4;
} else if(game.input.keyboard.isDown(Phaser.Keyboard.DOWN)) {
game.camera.scroll.y += 4;
}
}
function render() {
game.camera.renderDebugInfo(32, 32);
}
})();
+55
View File
@@ -0,0 +1,55 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
function init() {
game.world.setSize(1600, 800, true);
game.loader.addImageFile('disk', 'assets/pics/devilstar_demo_download_disk.png');
game.loader.load();
}
function create() {
for (var i = 0; i < 10; i++)
{
var temp:Phaser.Sprite = game.add.sprite(600 + (10 * i), 200 + (10 * i), 'disk');
temp.scrollFactor.setTo(i / 2, i / 2);
}
}
function update() {
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
{
game.camera.scroll.x -= 4;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
{
game.camera.scroll.x += 4;
}
if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
{
game.camera.scroll.y -= 4;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
{
game.camera.scroll.y += 4;
}
}
function render() {
game.camera.renderDebugInfo(32, 32);
}
})();
+12 -11
View File
@@ -3897,7 +3897,8 @@ var Phaser;
this.width = this.frameBounds.width;
this.height = this.frameBounds.height;
// Transform related (if we add any more then move to a component)
this.origin = new Phaser.Vec2(this.width / 2, this.height / 2);
//this.origin = new Phaser.Vec2(this.width / 2, this.height / 2);
this.origin = new Phaser.Vec2(0, 0);
this.scale = new Phaser.Vec2(1, 1);
this.skew = new Phaser.Vec2(0, 0);
}
@@ -4536,7 +4537,7 @@ var Phaser;
this._game.stage.context.fillText('X: ' + this._stageX + ' Y: ' + this._stageY + ' Rotation: ' + this._rotation, x, y + 14);
this._game.stage.context.fillText('World X: ' + this.scroll.x.toFixed(1) + ' World Y: ' + this.scroll.y.toFixed(1), x, y + 28);
if(this.bounds) {
this._game.stage.context.fillText('Bounds: ' + this.bounds.width + ' x ' + this.bounds.height, x, y + 56);
this._game.stage.context.fillText('Bounds: ' + this.bounds.width + ' x ' + this.bounds.height, x, y + 42);
}
};
Camera.prototype.destroy = /**
@@ -10481,6 +10482,10 @@ var Phaser;
this._fy = sprite.scale.y;
this._sin = 0;
this._cos = 1;
this._dx = (camera.scaledX * sprite.scrollFactor.x) + sprite.frameBounds.x - (camera.worldView.x * sprite.scrollFactor.x);
this._dy = (camera.scaledY * sprite.scrollFactor.y) + sprite.frameBounds.y - (camera.worldView.y * sprite.scrollFactor.y);
this._dw = sprite.frameBounds.width;
this._dh = sprite.frameBounds.height;
// Alpha
if(sprite.texture.alpha !== 1) {
this._ga = sprite.texture.context.globalAlpha;
@@ -10494,10 +10499,6 @@ var Phaser;
if(sprite.texture.flippedY) {
this._fy = -sprite.scale.y;
}
this._dx = (camera.scaledX * sprite.scrollFactor.x) + sprite.frameBounds.x - (camera.worldView.x * sprite.scrollFactor.x);
this._dy = (camera.scaledY * sprite.scrollFactor.y) + sprite.frameBounds.y - (camera.worldView.y * sprite.scrollFactor.y);
this._dw = sprite.frameBounds.width;
this._dh = sprite.frameBounds.height;
if(sprite.animations.currentFrame !== null) {
this._sx = sprite.animations.currentFrame.x;
this._sy = sprite.animations.currentFrame.y;
@@ -10532,11 +10533,11 @@ var Phaser;
this._dx = -sprite.origin.x;
this._dy = -sprite.origin.y;
} else {
this._dx -= sprite.origin.x;
this._dy -= sprite.origin.y;
//this._dw = sprite.frameBounds.width * sprite.scale.x;
//this._dh = sprite.frameBounds.height * sprite.scale.y;
}
if(!sprite.origin.equals(0)) {
this._dx -= sprite.origin.x;
this._dy -= sprite.origin.y;
}
}
this._sx = Math.round(this._sx);
this._sy = Math.round(this._sy);
this._sw = Math.round(this._sw);
+4 -21
View File
@@ -12,28 +12,11 @@
function create() {
// Here we'll assign the new sprite to the local bunny variable
bunny = game.add.sprite(0, 0, 'bunny');
// This time let's scale the sprite by using two tweens
// The first tween will scale the sprite up, the second will scale it down again
// Create our 2 tweens
tweenUp = game.add.tween(bunny.scale);
tweenUp.onComplete.add(scaleDown, this);
tweenDown = game.add.tween(bunny.scale);
tweenDown.onComplete.add(scaleUp, this);
// Start it going
scaleUp();
}
function scaleUp() {
tweenUp.to({
bunny.scale.setTo(0.5, 0.5);
// This time let's scale the sprite by a looped tween
game.add.tween(bunny.scale).to({
x: 2,
y: 2
}, 2000, Phaser.Easing.Elastic.Out);
tweenUp.start();
}
function scaleDown() {
tweenDown.to({
x: 0.5,
y: 0.5
}, 2000, Phaser.Easing.Elastic.Out);
tweenDown.start();
}, 2000, Phaser.Easing.Elastic.Out, true, 0, true, true);
}
})();
+3 -25
View File
@@ -21,32 +21,10 @@
// Here we'll assign the new sprite to the local bunny variable
bunny = game.add.sprite(0, 0, 'bunny');
// This time let's scale the sprite by using two tweens
// The first tween will scale the sprite up, the second will scale it down again
bunny.scale.setTo(0.5, 0.5);
// Create our 2 tweens
tweenUp = game.add.tween(bunny.scale);
tweenUp.onComplete.add(scaleDown, this);
tweenDown = game.add.tween(bunny.scale);
tweenDown.onComplete.add(scaleUp, this);
// Start it going
scaleUp();
}
function scaleUp() {
tweenUp.to({ x: 2, y: 2 }, 2000, Phaser.Easing.Elastic.Out);
tweenUp.start();
}
function scaleDown() {
tweenDown.to({ x: 0.5, y: 0.5 }, 2000, Phaser.Easing.Elastic.Out);
tweenDown.start();
// This time let's scale the sprite by a looped tween
game.add.tween(bunny.scale).to({ x: 2, y: 2 }, 2000, Phaser.Easing.Elastic.Out, true, 0, true, true);
}
+3 -12
View File
@@ -7,23 +7,14 @@
game.loader.load();
}
var fuji;
var tween;
function create() {
game.stage.backgroundColor = 'rgb(0,0,100)';
// Here we'll assign the new sprite to the local fuji variable
fuji = game.add.sprite(200, 200, 'fuji');
fuji = game.add.sprite(game.stage.centerX, game.stage.centerY, 'fuji');
// The sprite is 320 x 200 pixels in size
// If we don't set an origin then the sprite will rotate around 0,0 - the top left corner
tween = game.add.tween(fuji);
// Start it going
rotate();
}
function rotate() {
tween.clear();
tween.to({
game.add.tween(fuji).to({
rotation: 360
}, 2000);
tween.onComplete.add(rotate, this);
tween.start();
}, 2000, Phaser.Easing.Linear.None, true, 0, true);
}
})();
+2 -16
View File
@@ -13,31 +13,17 @@
}
var fuji: Phaser.Sprite;
var tween: Phaser.Tween;
function create() {
game.stage.backgroundColor = 'rgb(0,0,100)';
// Here we'll assign the new sprite to the local fuji variable
fuji = game.add.sprite(200, 200, 'fuji');
fuji = game.add.sprite(game.stage.centerX, game.stage.centerY, 'fuji');
// The sprite is 320 x 200 pixels in size
// If we don't set an origin then the sprite will rotate around 0,0 - the top left corner
tween = game.add.tween(fuji);
// Start it going
rotate();
}
function rotate() {
tween.clear();
tween.to({ rotation: 360 }, 2000);
tween.onComplete.add(rotate, this);
tween.start();
game.add.tween(fuji).to({ rotation: 360 }, 2000, Phaser.Easing.Linear.None, true, 0, true);
}
+3 -12
View File
@@ -7,25 +7,16 @@
game.loader.load();
}
var fuji;
var tween;
function create() {
game.stage.backgroundColor = 'rgb(0,0,100)';
// Here we'll assign the new sprite to the local fuji variable
fuji = game.add.sprite(200, 200, 'fuji');
fuji = game.add.sprite(game.stage.centerX, game.stage.centerY, 'fuji');
// The sprite is 320 x 200 pixels in size
// Here we set the origin to the center of the sprite (half of its width and height, so 160x100)
// This will cause it to rotate on its center
fuji.origin.setTo(160, 100);
tween = game.add.tween(fuji);
// Start it going
rotate();
}
function rotate() {
tween.clear();
tween.to({
game.add.tween(fuji).to({
rotation: 360
}, 2000);
tween.onComplete.add(rotate, this);
tween.start();
}, 2000, Phaser.Easing.Linear.None, true, 0, true);
}
})();
+2 -15
View File
@@ -13,33 +13,20 @@
}
var fuji: Phaser.Sprite;
var tween: Phaser.Tween;
function create() {
game.stage.backgroundColor = 'rgb(0,0,100)';
// Here we'll assign the new sprite to the local fuji variable
fuji = game.add.sprite(200, 200, 'fuji');
fuji = game.add.sprite(game.stage.centerX, game.stage.centerY, 'fuji');
// The sprite is 320 x 200 pixels in size
// Here we set the origin to the center of the sprite (half of its width and height, so 160x100)
// This will cause it to rotate on its center
fuji.origin.setTo(160, 100);
tween = game.add.tween(fuji);
// Start it going
rotate();
}
function rotate() {
tween.clear();
tween.to({ rotation: 360 }, 2000);
tween.onComplete.add(rotate, this);
tween.start();
game.add.tween(fuji).to({ rotation: 360 }, 2000, Phaser.Easing.Linear.None, true, 0, true);
}
+3 -11
View File
@@ -11,20 +11,12 @@
function create() {
game.stage.backgroundColor = 'rgb(0,0,100)';
// Here we'll assign the new sprite to the local fuji variable
fuji = game.add.sprite(300, 300, 'fuji');
fuji = game.add.sprite(game.stage.centerX, game.stage.centerY, 'fuji');
// The sprite is 320 x 200 pixels in size
// Here we set the origin to be the bottom-right of the sprite
fuji.origin.setTo(320, 200);
tween = game.add.tween(fuji);
// Start it going
rotate();
}
function rotate() {
tween.clear();
tween.to({
game.add.tween(fuji).to({
rotation: 360
}, 2000);
tween.onComplete.add(rotate, this);
tween.start();
}, 2000, Phaser.Easing.Linear.None, true, 0, true);
}
})();
+2 -14
View File
@@ -20,25 +20,13 @@
game.stage.backgroundColor = 'rgb(0,0,100)';
// Here we'll assign the new sprite to the local fuji variable
fuji = game.add.sprite(300, 300, 'fuji');
fuji = game.add.sprite(game.stage.centerX, game.stage.centerY, 'fuji');
// The sprite is 320 x 200 pixels in size
// Here we set the origin to be the bottom-right of the sprite
fuji.origin.setTo(320, 200);
tween = game.add.tween(fuji);
// Start it going
rotate();
}
function rotate() {
tween.clear();
tween.to({ rotation: 360 }, 2000);
tween.onComplete.add(rotate, this);
tween.start();
game.add.tween(fuji).to({ rotation: 360 }, 2000, Phaser.Easing.Linear.None, true, 0, true);
}
+3 -12
View File
@@ -7,7 +7,6 @@
game.loader.load();
}
var fuji;
var tweenRotate;
var tweenUp;
var tweenDown;
function create() {
@@ -17,23 +16,15 @@
// The sprite is 320 x 200 pixels in size
// Here we set the origin to the center of the sprite again, so we can rotate and scale it at the same time
fuji.origin.setTo(160, 100);
tweenRotate = game.add.tween(fuji);
game.add.tween(fuji).to({
rotation: 360
}, 2000, Phaser.Easing.Linear.None, true, 0, true);
tweenUp = game.add.tween(fuji.scale);
tweenUp.onComplete.add(scaleDown, this);
tweenDown = game.add.tween(fuji.scale);
tweenDown.onComplete.add(scaleUp, this);
// Start it going
rotate();
scaleUp();
}
function rotate() {
tweenRotate.clear();
tweenRotate.to({
rotation: 360
}, 2000);
tweenRotate.onComplete.add(rotate, this);
tweenRotate.start();
}
function scaleUp() {
tweenUp.to({
x: 2,
+1 -13
View File
@@ -13,7 +13,6 @@
}
var fuji: Phaser.Sprite;
var tweenRotate: Phaser.Tween;
var tweenUp: Phaser.Tween;
var tweenDown: Phaser.Tween;
@@ -28,7 +27,7 @@
// Here we set the origin to the center of the sprite again, so we can rotate and scale it at the same time
fuji.origin.setTo(160, 100);
tweenRotate = game.add.tween(fuji);
game.add.tween(fuji).to({ rotation: 360 }, 2000, Phaser.Easing.Linear.None, true, 0, true);
tweenUp = game.add.tween(fuji.scale);
tweenUp.onComplete.add(scaleDown, this);
@@ -36,21 +35,10 @@
tweenDown = game.add.tween(fuji.scale);
tweenDown.onComplete.add(scaleUp, this);
// Start it going
rotate();
scaleUp();
}
function rotate() {
tweenRotate.clear();
tweenRotate.to({ rotation: 360 }, 2000);
tweenRotate.onComplete.add(rotate, this);
tweenRotate.start();
}
function scaleUp() {
tweenUp.to({ x: 2, y: 2 }, 1000, Phaser.Easing.Elastic.Out);
+1 -3
View File
@@ -13,9 +13,7 @@
// Increase the size of the sprite a little so it covers the edges of the stage
swirl.scale.setTo(1.4, 1.4);
// Create a tween that rotates a full 306 degrees and then repeats (loop set to true)
game.add.tween(swirl).to({
rotation: 360
}, 2000, Phaser.Easing.Linear.None, true, 0, true);
//game.add.tween(swirl).to({ rotation: 360 }, 2000, Phaser.Easing.Linear.None, true, 0, true);
game.add.tween(swirl.scale).to({
x: 4,
y: 4
+12 -11
View File
@@ -3897,7 +3897,8 @@ var Phaser;
this.width = this.frameBounds.width;
this.height = this.frameBounds.height;
// Transform related (if we add any more then move to a component)
this.origin = new Phaser.Vec2(this.width / 2, this.height / 2);
//this.origin = new Phaser.Vec2(this.width / 2, this.height / 2);
this.origin = new Phaser.Vec2(0, 0);
this.scale = new Phaser.Vec2(1, 1);
this.skew = new Phaser.Vec2(0, 0);
}
@@ -4536,7 +4537,7 @@ var Phaser;
this._game.stage.context.fillText('X: ' + this._stageX + ' Y: ' + this._stageY + ' Rotation: ' + this._rotation, x, y + 14);
this._game.stage.context.fillText('World X: ' + this.scroll.x.toFixed(1) + ' World Y: ' + this.scroll.y.toFixed(1), x, y + 28);
if(this.bounds) {
this._game.stage.context.fillText('Bounds: ' + this.bounds.width + ' x ' + this.bounds.height, x, y + 56);
this._game.stage.context.fillText('Bounds: ' + this.bounds.width + ' x ' + this.bounds.height, x, y + 42);
}
};
Camera.prototype.destroy = /**
@@ -10481,6 +10482,10 @@ var Phaser;
this._fy = sprite.scale.y;
this._sin = 0;
this._cos = 1;
this._dx = (camera.scaledX * sprite.scrollFactor.x) + sprite.frameBounds.x - (camera.worldView.x * sprite.scrollFactor.x);
this._dy = (camera.scaledY * sprite.scrollFactor.y) + sprite.frameBounds.y - (camera.worldView.y * sprite.scrollFactor.y);
this._dw = sprite.frameBounds.width;
this._dh = sprite.frameBounds.height;
// Alpha
if(sprite.texture.alpha !== 1) {
this._ga = sprite.texture.context.globalAlpha;
@@ -10494,10 +10499,6 @@ var Phaser;
if(sprite.texture.flippedY) {
this._fy = -sprite.scale.y;
}
this._dx = (camera.scaledX * sprite.scrollFactor.x) + sprite.frameBounds.x - (camera.worldView.x * sprite.scrollFactor.x);
this._dy = (camera.scaledY * sprite.scrollFactor.y) + sprite.frameBounds.y - (camera.worldView.y * sprite.scrollFactor.y);
this._dw = sprite.frameBounds.width;
this._dh = sprite.frameBounds.height;
if(sprite.animations.currentFrame !== null) {
this._sx = sprite.animations.currentFrame.x;
this._sy = sprite.animations.currentFrame.y;
@@ -10532,11 +10533,11 @@ var Phaser;
this._dx = -sprite.origin.x;
this._dy = -sprite.origin.y;
} else {
this._dx -= sprite.origin.x;
this._dy -= sprite.origin.y;
//this._dw = sprite.frameBounds.width * sprite.scale.x;
//this._dh = sprite.frameBounds.height * sprite.scale.y;
}
if(!sprite.origin.equals(0)) {
this._dx -= sprite.origin.x;
this._dy -= sprite.origin.y;
}
}
this._sx = Math.round(this._sx);
this._sy = Math.round(this._sy);
this._sw = Math.round(this._sw);