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 :)

This commit is contained in:
photonstorm
2014-03-07 01:26:09 +00:00
parent 3b2573de9a
commit a51ae03246
8 changed files with 70 additions and 31 deletions
+1
View File
@@ -143,6 +143,7 @@ New features:
* Tween.generateData(frameRate) allows you to generate tween data into an array, which can then be used however you wish (see new examples)
* Group.xy(index, x, y) allows you to set the x and y coordinates of a Group child at the given index.
* Group.reverse() reverses the display order of all children in the Group.
* 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 :)
Updates:
+20 -8
View File
@@ -141,14 +141,26 @@
<script src="../src/utils/Debug.js"></script>
<script src="../src/utils/Color.js"></script>
<script src="../src/physics/World.js"></script>
<script src="../src/physics/PointProxy.js"></script>
<script src="../src/physics/InversePointProxy.js"></script>
<script src="../src/physics/Body.js"></script>
<script src="../src/physics/Spring.js"></script>
<script src="../src/physics/Material.js"></script>
<script src="../src/physics/ContactMaterial.js"></script>
<script src="../src/physics/CollisionGroup.js"></script>
<script src="../src/physics/Physics.js"></script>
<script src="../src/physics/arcade/World.js"></script>
<script src="../src/physics/arcade/Body.js"></script>
<script src="../src/physics/arcade/QuadTree.js"></script>
<script src="../src/physics/ninja/World.js"></script>
<script src="../src/physics/ninja/Body.js"></script>
<script src="../src/physics/ninja/AABB.js"></script>
<script src="../src/physics/ninja/Tile.js"></script>
<script src="../src/physics/ninja/Circle.js"></script>
<script src="../src/physics/p2/World.js"></script>
<script src="../src/physics/p2/PointProxy.js"></script>
<script src="../src/physics/p2/InversePointProxy.js"></script>
<script src="../src/physics/p2/Body.js"></script>
<script src="../src/physics/p2/Spring.js"></script>
<script src="../src/physics/p2/Material.js"></script>
<script src="../src/physics/p2/ContactMaterial.js"></script>
<script src="../src/physics/p2/CollisionGroup.js"></script>
<script src="../src/particles/Particles.js"></script>
<script src="../src/particles/arcade/ArcadeParticles.js"></script>
+20 -8
View File
@@ -141,14 +141,26 @@
<script src="../src/utils/Debug.js"></script>
<script src="../src/utils/Color.js"></script>
<script src="../src/physics/World.js"></script>
<script src="../src/physics/PointProxy.js"></script>
<script src="../src/physics/InversePointProxy.js"></script>
<script src="../src/physics/Body.js"></script>
<script src="../src/physics/Spring.js"></script>
<script src="../src/physics/Material.js"></script>
<script src="../src/physics/ContactMaterial.js"></script>
<script src="../src/physics/CollisionGroup.js"></script>
<script src="../src/physics/Physics.js"></script>
<script src="../src/physics/arcade/World.js"></script>
<script src="../src/physics/arcade/Body.js"></script>
<script src="../src/physics/arcade/QuadTree.js"></script>
<script src="../src/physics/ninja/World.js"></script>
<script src="../src/physics/ninja/Body.js"></script>
<script src="../src/physics/ninja/AABB.js"></script>
<script src="../src/physics/ninja/Tile.js"></script>
<script src="../src/physics/ninja/Circle.js"></script>
<script src="../src/physics/p2/World.js"></script>
<script src="../src/physics/p2/PointProxy.js"></script>
<script src="../src/physics/p2/InversePointProxy.js"></script>
<script src="../src/physics/p2/Body.js"></script>
<script src="../src/physics/p2/Spring.js"></script>
<script src="../src/physics/p2/Material.js"></script>
<script src="../src/physics/p2/ContactMaterial.js"></script>
<script src="../src/physics/p2/CollisionGroup.js"></script>
<script src="../src/particles/Particles.js"></script>
<script src="../src/particles/arcade/ArcadeParticles.js"></script>
+17 -8
View File
@@ -1,7 +1,10 @@
var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create });
function preload() {
var text;
var counter = 0;
function preload () {
// You can fill the preloader with as many assets as your game requires
@@ -10,24 +13,30 @@ function preload() {
// The second parameter is the URL of the image (relative)
game.load.image('einstein', 'assets/pics/ra_einstein.png');
}
function create() {
// This creates a simple sprite that is using our loaded image and
// displays it on-screen
// and assign it to a variable
var image = game.add.sprite(0, 0, 'einstein');
// displays it on-screen and assign it to a variable
var image = game.add.sprite(game.world.centerX, game.world.centerY, 'einstein');
//enables all kind of input actions on this image (click, etc)
image.inputEnabled=true;
// Moves the image anchor to the middle, so it centers inside the game properly
image.anchor.set(0.5);
image.events.onInputDown.add(listener,this);
// Enables all kind of input actions on this image (click, etc)
image.inputEnabled = true;
text = game.add.text(250, 16, '', { fill: '#ffffff' });
image.events.onInputDown.add(listener, this);
}
function listener () {
alert('clicked');
counter++;
text.text = "You clicked " + counter + " times!";
}
+5 -2
View File
@@ -18,7 +18,7 @@ function create() {
game.world.setBounds(0, 0, 1920, 1200);
game.add.image(0, 0, 'backdrop');
mushroom = game.add.sprite(400, 400, 'mushroom');
mushroom = game.add.sprite(100, 100, 'mushroom');
// Test Fixing an Image to the Camera
var fixie = game.add.image(100, 100, 'coke');
@@ -50,9 +50,12 @@ function create() {
// Button! do mouse events still work then?
game.camera.scale.set(2);
// game.world.pivot.set(400, 300);
// game.camera.scale.set(2);
game.camera.follow(mushroom);
game.camera.deadzone = new Phaser.Rectangle(200, 150, 400, 300);
// game.camera.deadzone = new Phaser.Rectangle(0, 0, 800, 600);
cursors = game.input.keyboard.createCursorKeys();
+2 -2
View File
@@ -127,8 +127,8 @@ Phaser.Camera.prototype = {
/**
* Tells this camera which sprite to follow.
* @method Phaser.Camera#follow
* @param {Phaser.Sprite} target - The object you want the camera to track. Set to null to not follow anything.
* @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().
* @param {Phaser.Sprite|Phaser.Image|Phaser.Text} target - The object you want the camera to track. Set to null to not follow anything.
* @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().
*/
follow: function (target, style) {
+3 -2
View File
@@ -12,8 +12,9 @@
* @constructor
* @param {object} object - Target object will be affected by this tween.
* @param {Phaser.Game} game - Current game instance.
* @param {Phaser.TweenManager} manager - The TweenManager responsible for looking after this Tween.
*/
Phaser.Tween = function (object, game) {
Phaser.Tween = function (object, game, manager) {
/**
* Reference to the target object.
@@ -31,7 +32,7 @@ Phaser.Tween = function (object, game) {
* @property {Phaser.TweenManager} _manager - Reference to the TweenManager.
* @private
*/
this._manager = this.game.tweens;
this._manager = manager;
/**
* @property {object} _valuesStart - Private value object.
+2 -1
View File
@@ -81,6 +81,7 @@ Phaser.TweenManager.prototype = {
*/
add: function (tween) {
tween._manager = this;
this._add.push(tween);
},
@@ -94,7 +95,7 @@ Phaser.TweenManager.prototype = {
*/
create: function (object) {
return new Phaser.Tween(object, this.game);
return new Phaser.Tween(object, this.game, this);
},