Skip to content

Commit a51ae03

Browse files
committed
Tweens are now bound to their own TweenManager, not always the global game one. So you can create your own managers now (for you clark :)
1 parent 3b2573d commit a51ae03

8 files changed

Lines changed: 70 additions & 31 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ New features:
143143
* Tween.generateData(frameRate) allows you to generate tween data into an array, which can then be used however you wish (see new examples)
144144
* Group.xy(index, x, y) allows you to set the x and y coordinates of a Group child at the given index.
145145
* Group.reverse() reverses the display order of all children in the Group.
146+
* Tweens are now bound to their own TweenManager, not always the global game one. So you can create your own managers now (for you clark :)
146147

147148

148149
Updates:

examples/_site/view_full.html

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,26 @@
141141
<script src="../src/utils/Debug.js"></script>
142142
<script src="../src/utils/Color.js"></script>
143143

144-
<script src="../src/physics/World.js"></script>
145-
<script src="../src/physics/PointProxy.js"></script>
146-
<script src="../src/physics/InversePointProxy.js"></script>
147-
<script src="../src/physics/Body.js"></script>
148-
<script src="../src/physics/Spring.js"></script>
149-
<script src="../src/physics/Material.js"></script>
150-
<script src="../src/physics/ContactMaterial.js"></script>
151-
<script src="../src/physics/CollisionGroup.js"></script>
144+
<script src="../src/physics/Physics.js"></script>
145+
146+
<script src="../src/physics/arcade/World.js"></script>
147+
<script src="../src/physics/arcade/Body.js"></script>
148+
<script src="../src/physics/arcade/QuadTree.js"></script>
149+
150+
<script src="../src/physics/ninja/World.js"></script>
151+
<script src="../src/physics/ninja/Body.js"></script>
152+
<script src="../src/physics/ninja/AABB.js"></script>
153+
<script src="../src/physics/ninja/Tile.js"></script>
154+
<script src="../src/physics/ninja/Circle.js"></script>
155+
156+
<script src="../src/physics/p2/World.js"></script>
157+
<script src="../src/physics/p2/PointProxy.js"></script>
158+
<script src="../src/physics/p2/InversePointProxy.js"></script>
159+
<script src="../src/physics/p2/Body.js"></script>
160+
<script src="../src/physics/p2/Spring.js"></script>
161+
<script src="../src/physics/p2/Material.js"></script>
162+
<script src="../src/physics/p2/ContactMaterial.js"></script>
163+
<script src="../src/physics/p2/CollisionGroup.js"></script>
152164

153165
<script src="../src/particles/Particles.js"></script>
154166
<script src="../src/particles/arcade/ArcadeParticles.js"></script>

examples/_site/view_lite.html

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,26 @@
141141
<script src="../src/utils/Debug.js"></script>
142142
<script src="../src/utils/Color.js"></script>
143143

144-
<script src="../src/physics/World.js"></script>
145-
<script src="../src/physics/PointProxy.js"></script>
146-
<script src="../src/physics/InversePointProxy.js"></script>
147-
<script src="../src/physics/Body.js"></script>
148-
<script src="../src/physics/Spring.js"></script>
149-
<script src="../src/physics/Material.js"></script>
150-
<script src="../src/physics/ContactMaterial.js"></script>
151-
<script src="../src/physics/CollisionGroup.js"></script>
144+
<script src="../src/physics/Physics.js"></script>
145+
146+
<script src="../src/physics/arcade/World.js"></script>
147+
<script src="../src/physics/arcade/Body.js"></script>
148+
<script src="../src/physics/arcade/QuadTree.js"></script>
149+
150+
<script src="../src/physics/ninja/World.js"></script>
151+
<script src="../src/physics/ninja/Body.js"></script>
152+
<script src="../src/physics/ninja/AABB.js"></script>
153+
<script src="../src/physics/ninja/Tile.js"></script>
154+
<script src="../src/physics/ninja/Circle.js"></script>
155+
156+
<script src="../src/physics/p2/World.js"></script>
157+
<script src="../src/physics/p2/PointProxy.js"></script>
158+
<script src="../src/physics/p2/InversePointProxy.js"></script>
159+
<script src="../src/physics/p2/Body.js"></script>
160+
<script src="../src/physics/p2/Spring.js"></script>
161+
<script src="../src/physics/p2/Material.js"></script>
162+
<script src="../src/physics/p2/ContactMaterial.js"></script>
163+
<script src="../src/physics/p2/CollisionGroup.js"></script>
152164

153165
<script src="../src/particles/Particles.js"></script>
154166
<script src="../src/particles/arcade/ArcadeParticles.js"></script>
Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11

22
var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create });
33

4-
function preload() {
4+
var text;
5+
var counter = 0;
6+
7+
function preload () {
58

69
// You can fill the preloader with as many assets as your game requires
710

@@ -10,24 +13,30 @@ function preload() {
1013

1114
// The second parameter is the URL of the image (relative)
1215
game.load.image('einstein', 'assets/pics/ra_einstein.png');
16+
1317
}
1418

1519
function create() {
1620

1721
// This creates a simple sprite that is using our loaded image and
18-
// displays it on-screen
19-
// and assign it to a variable
20-
var image = game.add.sprite(0, 0, 'einstein');
22+
// displays it on-screen and assign it to a variable
23+
var image = game.add.sprite(game.world.centerX, game.world.centerY, 'einstein');
2124

22-
//enables all kind of input actions on this image (click, etc)
23-
image.inputEnabled=true;
25+
// Moves the image anchor to the middle, so it centers inside the game properly
26+
image.anchor.set(0.5);
2427

25-
image.events.onInputDown.add(listener,this);
28+
// Enables all kind of input actions on this image (click, etc)
29+
image.inputEnabled = true;
2630

31+
text = game.add.text(250, 16, '', { fill: '#ffffff' });
2732

33+
image.events.onInputDown.add(listener, this);
2834

2935
}
3036

3137
function listener () {
32-
alert('clicked');
38+
39+
counter++;
40+
text.text = "You clicked " + counter + " times!";
41+
3342
}

examples/wip/fixed to cam scale.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function create() {
1818
game.world.setBounds(0, 0, 1920, 1200);
1919
game.add.image(0, 0, 'backdrop');
2020

21-
mushroom = game.add.sprite(400, 400, 'mushroom');
21+
mushroom = game.add.sprite(100, 100, 'mushroom');
2222

2323
// Test Fixing an Image to the Camera
2424
var fixie = game.add.image(100, 100, 'coke');
@@ -50,9 +50,12 @@ function create() {
5050

5151
// Button! do mouse events still work then?
5252

53-
game.camera.scale.set(2);
53+
// game.world.pivot.set(400, 300);
54+
// game.camera.scale.set(2);
5455

5556
game.camera.follow(mushroom);
57+
game.camera.deadzone = new Phaser.Rectangle(200, 150, 400, 300);
58+
// game.camera.deadzone = new Phaser.Rectangle(0, 0, 800, 600);
5659

5760
cursors = game.input.keyboard.createCursorKeys();
5861

src/core/Camera.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ Phaser.Camera.prototype = {
127127
/**
128128
* Tells this camera which sprite to follow.
129129
* @method Phaser.Camera#follow
130-
* @param {Phaser.Sprite} target - The object you want the camera to track. Set to null to not follow anything.
131-
* @param {number} [style] Leverage one of the existing "deadzone" presets. If you use a custom deadzone, ignore this parameter and manually specify the deadzone after calling follow().
130+
* @param {Phaser.Sprite|Phaser.Image|Phaser.Text} target - The object you want the camera to track. Set to null to not follow anything.
131+
* @param {number} [style] - Leverage one of the existing "deadzone" presets. If you use a custom deadzone, ignore this parameter and manually specify the deadzone after calling follow().
132132
*/
133133
follow: function (target, style) {
134134

src/tween/Tween.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212
* @constructor
1313
* @param {object} object - Target object will be affected by this tween.
1414
* @param {Phaser.Game} game - Current game instance.
15+
* @param {Phaser.TweenManager} manager - The TweenManager responsible for looking after this Tween.
1516
*/
16-
Phaser.Tween = function (object, game) {
17+
Phaser.Tween = function (object, game, manager) {
1718

1819
/**
1920
* Reference to the target object.
@@ -31,7 +32,7 @@ Phaser.Tween = function (object, game) {
3132
* @property {Phaser.TweenManager} _manager - Reference to the TweenManager.
3233
* @private
3334
*/
34-
this._manager = this.game.tweens;
35+
this._manager = manager;
3536

3637
/**
3738
* @property {object} _valuesStart - Private value object.

src/tween/TweenManager.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ Phaser.TweenManager.prototype = {
8181
*/
8282
add: function (tween) {
8383

84+
tween._manager = this;
8485
this._add.push(tween);
8586

8687
},
@@ -94,7 +95,7 @@ Phaser.TweenManager.prototype = {
9495
*/
9596
create: function (object) {
9697

97-
return new Phaser.Tween(object, this.game);
98+
return new Phaser.Tween(object, this.game, this);
9899

99100
},
100101

0 commit comments

Comments
 (0)