diff --git a/README.md b/README.md index fa1cc844e2..d317c2cc51 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ Exactly 6 months ago we released Phaser 1.0 into the world. Suffice to say that And we're also really pleased to have closed down over 550 issues reported on github. We literally went through every last bug reported to us, and fixed it. All kinds of little things that as a whole make the library that much more solid. With the 2.0 release we're now freezing the API. Before we have to admit that the API changed somewhat on a whim, and we moved things around and changed things without too much consideration for fellow developers. With 2.0 that stops - we've spent long enough on this release that we're now extremely happy with the organisation of classes and methods, and while we may still need to make small tweaks in the future, none of them will be API breaking without prior community approval first. This means if you're using Phaser to teach in classes, or writing a book / tutorials around it, this is the version to base off. -If you want to port a Phaser 1.x game over to 2 then please see our [Migration Guide]() for help. +If you want to port a Phaser 1.x game over to 2 then please see our [Migration Guide](https://github.com/photonstorm/phaser/blob/master/resources/Migration%20Guide.md) for help. So what's next? We do have a roadmap (which you can find at the bottom of this document), but we're going to sit back and take stock for a while, building up the tutorials and sample games. We will of course jump on bug fixes quickly, and we appreciate that our TypeScript definitions are now slightly out of date again (an eternal quest we appear to be on!), but this is definitely the best release of Phaser ever. The most features, the fastest, the most stable and just generally the most fun to use. @@ -55,7 +55,7 @@ Change Log Version 2.0.0 - "Aes Sedai" - March 13th 2014 -There is an extensive Migration Guide available. In the guide we detail the API breaking changes and approach to our new physics system. The following is a list of all the other new features, updates and bug fixes present in this release. +There is an extensive [Migration Guide](https://github.com/photonstorm/phaser/blob/master/resources/Migration%20Guide.md) available. In the guide we detail the API breaking changes and approach to our new physics system. The following is a list of all the other new features, updates and bug fixes present in this release. New features: @@ -241,11 +241,11 @@ CDNJS Thanks to a community member Phaser is now available on [CDNJS](http://cdnjs.com). You can include the following in your html: -`http://cdnjs.cloudflare.com/ajax/libs/phaser/1.1.3/phaser.min.js` +`http://cdnjs.cloudflare.com/ajax/libs/phaser/2.0.0/phaser.min.js` Or if you prefer you can leave the protocol off, so it works via http and https: -`//cdnjs.cloudflare.com/ajax/libs/phaser/1.1.3/phaser.min.js` +`//cdnjs.cloudflare.com/ajax/libs/phaser/2.0.0/phaser.min.js` Requirements @@ -255,7 +255,7 @@ Games created with Phaser require a modern web browser that supports the canvas For developing with Phaser you can use either a plain-vanilla JavaScript approach or [TypeScript](https://typescript.codeplex.com/) using the provided TypeScript definitions file. We made no assumptions about how you like to code your games, and were careful not to impose any form of class/inheritance/structure upon you. -Phaser is 576 KB minified (including all 3 physics engines, 311KB without) and 128 KB gzipped (67KB without). +Phaser is 576 KB minified (including all 3 physics engines, 311 KB without) and 128 KB gzipped (67 KB without physics libs). Learn By Example diff --git a/docs/AABB.js.html b/docs/AABB.js.html new file mode 100644 index 0000000000..0d9f2b4370 --- /dev/null +++ b/docs/AABB.js.html @@ -0,0 +1,1581 @@ + + + + + + Phaser Source: physics/ninja/AABB.js + + + + + + + + + + +
+ + +
+ + +
+ +
+ + + +

Source: physics/ninja/AABB.js

+ +
+
+
/**
+* @author       Richard Davey <rich@photonstorm.com>
+* @copyright    2014 Photon Storm Ltd.
+* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
+*/
+
+/**
+* Ninja Physics AABB constructor.
+* Note: This class could be massively optimised and reduced in size. I leave that challenge up to you.
+*
+* @class Phaser.Physics.Ninja.AABB
+* @classdesc Arcade Physics Constructor
+* @constructor
+* @param {Phaser.Physics.Ninja.Body} body - The body that owns this shape.
+* @param {number} x - The x coordinate to create this shape at.
+* @param {number} y - The y coordinate to create this shape at.
+* @param {number} width - The width of this AABB.
+* @param {number} height - The height of this AABB.
+*/
+Phaser.Physics.Ninja.AABB = function (body, x, y, width, height) {
+    
+    /**
+    * @property {Phaser.Physics.Ninja.Body} system - A reference to the body that owns this shape.
+    */
+    this.body = body;
+
+    /**
+    * @property {Phaser.Physics.Ninja} system - A reference to the physics system.
+    */
+    this.system = body.system;
+
+    /**
+    * @property {Phaser.Point} pos - The position of this object.
+    */
+    this.pos = new Phaser.Point(x, y);
+
+    /**
+    * @property {Phaser.Point} oldpos - The position of this object in the previous update.
+    */
+    this.oldpos = new Phaser.Point(x, y);
+
+    /**
+    * @property {number} xw - Half the width.
+    * @readonly
+    */
+    this.xw = Math.abs(width / 2);
+
+    /**
+    * @property {number} xw - Half the height.
+    * @readonly
+    */
+    this.yw = Math.abs(height / 2);
+
+    /**
+    * @property {number} width - The width.
+    * @readonly
+    */
+    this.width = width;
+
+    /**
+    * @property {number} height - The height.
+    * @readonly
+    */
+    this.height = height;
+
+    /**
+    * @property {number} oH - Internal var.
+    * @private
+    */
+    this.oH = 0;
+
+    /**
+    * @property {number} oV - Internal var.
+    * @private
+    */
+    this.oV = 0;
+
+    /**
+    * @property {Phaser.Point} velocity - The velocity of this object.
+    */
+    this.velocity = new Phaser.Point();
+
+    /**
+    * @property {object} aabbTileProjections - All of the collision response handlers.
+    */
+    this.aabbTileProjections = {};
+
+    this.aabbTileProjections[Phaser.Physics.Ninja.Tile.TYPE_FULL] = this.projAABB_Full;
+    this.aabbTileProjections[Phaser.Physics.Ninja.Tile.TYPE_45DEG] = this.projAABB_45Deg;
+    this.aabbTileProjections[Phaser.Physics.Ninja.Tile.TYPE_CONCAVE] = this.projAABB_Concave;
+    this.aabbTileProjections[Phaser.Physics.Ninja.Tile.TYPE_CONVEX] = this.projAABB_Convex;
+    this.aabbTileProjections[Phaser.Physics.Ninja.Tile.TYPE_22DEGs] = this.projAABB_22DegS;
+    this.aabbTileProjections[Phaser.Physics.Ninja.Tile.TYPE_22DEGb] = this.projAABB_22DegB;
+    this.aabbTileProjections[Phaser.Physics.Ninja.Tile.TYPE_67DEGs] = this.projAABB_67DegS;
+    this.aabbTileProjections[Phaser.Physics.Ninja.Tile.TYPE_67DEGb] = this.projAABB_67DegB;
+    this.aabbTileProjections[Phaser.Physics.Ninja.Tile.TYPE_HALF] = this.projAABB_Half;
+
+};
+
+Phaser.Physics.Ninja.AABB.prototype.constructor = Phaser.Physics.Ninja.AABB;
+
+Phaser.Physics.Ninja.AABB.COL_NONE = 0;
+Phaser.Physics.Ninja.AABB.COL_AXIS = 1;
+Phaser.Physics.Ninja.AABB.COL_OTHER = 2;
+
+Phaser.Physics.Ninja.AABB.prototype = {
+
+    /**
+    * Updates this AABBs position.
+    *
+    * @method Phaser.Physics.Ninja.AABB#integrate
+    */
+    integrate: function () {
+
+        var px = this.pos.x;
+        var py = this.pos.y;
+
+        //  integrate
+        this.pos.x += (this.body.drag * this.pos.x) - (this.body.drag * this.oldpos.x);
+        this.pos.y += (this.body.drag * this.pos.y) - (this.body.drag * this.oldpos.y) + (this.system.gravity * this.body.gravityScale);
+
+        //  store
+        this.velocity.set(this.pos.x - px, this.pos.y - py);
+        this.oldpos.set(px, py);
+
+    },
+
+    /**
+    * Process a world collision and apply the resulting forces.
+    *
+    * @method Phaser.Physics.Ninja.AABB#reportCollisionVsWorld
+    * @param {number} px - The tangent velocity
+    * @param {number} py - The tangent velocity
+    * @param {number} dx - Collision normal
+    * @param {number} dy - Collision normal
+    * @param {number} obj - Object this AABB collided with
+    */
+    reportCollisionVsWorld: function (px, py, dx, dy, obj) {
+
+        var p = this.pos;
+        var o = this.oldpos;
+
+        //  Calc velocity
+        var vx = p.x - o.x;
+        var vy = p.y - o.y;
+
+        //  Find component of velocity parallel to collision normal
+        var dp = (vx * dx + vy * dy);
+        var nx = dp * dx;   //project velocity onto collision normal
+
+        var ny = dp * dy;   //nx,ny is normal velocity
+
+        var tx = vx - nx;   //px,py is tangent velocity
+        var ty = vy - ny;
+
+        //  We only want to apply collision response forces if the object is travelling into, and not out of, the collision
+        var b, bx, by, fx, fy;
+
+        if (dp < 0)
+        {
+            fx = tx * this.body.friction;
+            fy = ty * this.body.friction;
+
+            b = 1 + this.body.bounce;
+
+            bx = (nx * b);
+            by = (ny * b);
+
+            if (dx === 1)
+            {
+                this.body.touching.left = true;
+            }
+            else if (dx === -1)
+            {
+                this.body.touching.right = true;
+            }
+
+            if (dy === 1)
+            {
+                this.body.touching.up = true;
+            }
+            else if (dy === -1)
+            {
+                this.body.touching.down = true;
+            }
+        }
+        else
+        {
+            //  Moving out of collision, do not apply forces
+            bx = by = fx = fy = 0;
+        }
+
+        //  Project object out of collision
+        p.x += px;
+        p.y += py;
+
+        //  Apply bounce+friction impulses which alter velocity
+        o.x += px + bx + fx;
+        o.y += py + by + fy;
+
+    },
+
+    reverse: function () {
+
+        var vx = this.pos.x - this.oldpos.x;
+        var vy = this.pos.y - this.oldpos.y;
+
+        if (this.oldpos.x < this.pos.x)
+        {
+            this.oldpos.x = this.pos.x + vx;
+            // this.oldpos.x = this.pos.x + (vx + 1 + this.body.bounce);
+        }
+        else if (this.oldpos.x > this.pos.x)
+        {
+            this.oldpos.x = this.pos.x - vx;
+            // this.oldpos.x = this.pos.x - (vx + 1 + this.body.bounce);
+        }
+
+        if (this.oldpos.y < this.pos.y)
+        {
+            this.oldpos.y = this.pos.y + vy;
+            // this.oldpos.y = this.pos.y + (vy + 1 + this.body.bounce);
+        }
+        else if (this.oldpos.y > this.pos.y)
+        {
+            this.oldpos.y = this.pos.y - vy;
+            // this.oldpos.y = this.pos.y - (vy + 1 + this.body.bounce);
+        }
+
+    },
+
+    /**
+    * Process a body collision and apply the resulting forces. Still very much WIP and doesn't work fully. Feel free to fix!
+    *
+    * @method Phaser.Physics.Ninja.AABB#reportCollisionVsBody
+    * @param {number} px - The tangent velocity
+    * @param {number} py - The tangent velocity
+    * @param {number} dx - Collision normal
+    * @param {number} dy - Collision normal
+    * @param {number} obj - Object this AABB collided with
+    */
+    reportCollisionVsBody: function (px, py, dx, dy, obj) {
+
+        var vx1 = this.pos.x - this.oldpos.x;   //  Calc velocity of this object
+        var vy1 = this.pos.y - this.oldpos.y;
+        var dp1 = (vx1 * dx + vy1 * dy);         //  Find component of velocity parallel to collision normal
+        var nx1 = dp1 * dx;                      //  Project velocity onto collision normal
+        var ny1 = dp1 * dy;                      //  nx, ny is normal velocity
+
+        var dx2 = dx * -1;
+        var dy2 = dy * -1;
+        var vx2 = obj.pos.x - obj.oldpos.x;      //  Calc velocity of colliding object
+        var vy2 = obj.pos.y - obj.oldpos.y;
+        var dp2 = (vx2 * dx2 + vy2 * dy2);         //  Find component of velocity parallel to collision normal
+        var nx2 = dp2 * dx2;                      //  Project velocity onto collision normal
+        var ny2 = dp2 * dy2;                      //  nx, ny is normal velocity
+
+        //  We only want to apply collision response forces if the object is travelling into, and not out of, the collision
+        if (this.body.immovable && obj.body.immovable)
+        {
+            //  Split the separation then return, no forces applied as they come to a stand-still
+            px *= 0.5;
+            py *= 0.5;
+
+            this.pos.add(px, py);
+            this.oldpos.set(this.pos.x, this.pos.y);
+
+            obj.pos.subtract(px, py);
+            obj.oldpos.set(obj.pos.x, obj.pos.y);
+
+            return;
+        }
+        else if (!this.body.immovable && !obj.body.immovable)
+        {
+            //  separate
+            px *= 0.5;
+            py *= 0.5;
+
+            this.pos.add(px, py);
+            obj.pos.subtract(px, py);
+
+            if (dp1 < 0)
+            {
+                this.reverse();
+                obj.reverse();
+            }
+        }
+        else if (!this.body.immovable)
+        {
+            this.pos.subtract(px, py);
+
+            if (dp1 < 0)
+            {
+                this.reverse();
+            }
+        }
+        else if (!obj.body.immovable)
+        {
+            obj.pos.subtract(px, py);
+
+            if (dp1 < 0)
+            {
+                obj.reverse();
+            }
+        }
+
+    },
+
+    /**
+    * Collides this AABB against the world bounds.
+    *
+    * @method Phaser.Physics.Ninja.AABB#collideWorldBounds
+    */
+    collideWorldBounds: function () {
+
+        var dx = this.system.bounds.x - (this.pos.x - this.xw);
+
+        if (0 < dx)
+        {
+            this.reportCollisionVsWorld(dx, 0, 1, 0, null);
+        }
+        else
+        {
+            dx = (this.pos.x + this.xw) - this.system.bounds.width;
+
+            if (0 < dx)
+            {
+                this.reportCollisionVsWorld(-dx, 0, -1, 0, null);
+            }
+        }
+
+        var dy = this.system.bounds.y - (this.pos.y - this.yw);
+
+        if (0 < dy)
+        {
+            this.reportCollisionVsWorld(0, dy, 0, 1, null);
+        }
+        else
+        {
+            dy = (this.pos.y + this.yw) - this.system.bounds.height;
+
+            if (0 < dy)
+            {
+                this.reportCollisionVsWorld(0, -dy, 0, -1, null);
+            }
+        }
+
+    },
+
+    /**
+    * Collides this AABB against a AABB.
+    *
+    * @method Phaser.Physics.Ninja.AABB#collideAABBVsAABB
+    * @param {Phaser.Physics.Ninja.AABB} aabb - The AABB to collide against.
+    */
+    collideAABBVsAABB: function (aabb) {
+
+        var pos = this.pos;
+        var c = aabb;
+
+        var tx = c.pos.x;
+        var ty = c.pos.y;
+        var txw = c.xw;
+        var tyw = c.yw;
+
+        var dx = pos.x - tx;//tile->obj delta
+        var px = (txw + this.xw) - Math.abs(dx);//penetration depth in x
+
+        if (0 < px)
+        {
+            var dy = pos.y - ty;//tile->obj delta
+            var py = (tyw + this.yw) - Math.abs(dy);//pen depth in y
+
+            if (0 < py)
+            {
+                //object may be colliding with tile; call tile-specific collision function
+
+                //calculate projection vectors
+                if (px < py)
+                {
+                    //project in x
+                    if (dx < 0)
+                    {
+                        //project to the left
+                        px *= -1;
+                        py = 0;
+                    }
+                    else
+                    {
+                        //proj to right
+                        py = 0;
+                    }
+                }
+                else
+                {
+                    //project in y
+                    if (dy < 0)
+                    {
+                        //project up
+                        px = 0;
+                        py *= -1;
+                    }
+                    else
+                    {
+                        //project down
+                        px = 0;
+                    }
+                }
+
+                var l = Math.sqrt(px * px + py * py);
+                this.reportCollisionVsBody(px, py, px / l, py / l, c);
+
+                return Phaser.Physics.Ninja.AABB.COL_AXIS;
+
+            }
+        }
+
+        return false;
+
+    },
+
+    /**
+    * Collides this AABB against a Tile.
+    *
+    * @method Phaser.Physics.Ninja.AABB#collideAABBVsTile
+    * @param {Phaser.Physics.Ninja.Tile} tile - The Tile to collide against.
+    */
+    collideAABBVsTile: function (tile) {
+
+        var dx = this.pos.x - tile.pos.x;               //  tile->obj delta
+        var px = (tile.xw + this.xw) - Math.abs(dx);    //  penetration depth in x
+
+        if (0 < px)
+        {
+            var dy = this.pos.y - tile.pos.y;               //  tile->obj delta
+            var py = (tile.yw + this.yw) - Math.abs(dy);    //  pen depth in y
+
+            if (0 < py)
+            {
+                //  Calculate projection vectors
+                if (px < py)
+                {
+                    //  Project in x
+                    if (dx < 0)
+                    {
+                        //  Project to the left
+                        px *= -1;
+                        py = 0;
+                    }
+                    else
+                    {
+                        //  Project to the right
+                        py = 0;
+                    }
+                }
+                else
+                {
+                    //  Project in y
+                    if (dy < 0)
+                    {
+                        //  Project up
+                        px = 0;
+                        py *= -1;
+                    }
+                    else
+                    {
+                        //  Project down
+                        px = 0;
+                    }
+                }
+
+                //  Object may be colliding with tile; call tile-specific collision function
+                return this.resolveTile(px, py, this, tile);
+            }
+        }
+
+        return false;
+
+    },
+
+    /**
+    * Resolves tile collision.
+    *
+    * @method Phaser.Physics.Ninja.AABB#resolveTile
+    * @param {number} x - Penetration depth on the x axis.
+    * @param {number} y - Penetration depth on the y axis.
+    * @param {Phaser.Physics.Ninja.AABB} body - The AABB involved in the collision.
+    * @param {Phaser.Physics.Ninja.Tile} tile - The Tile involved in the collision.
+    * @return {boolean} True if the collision was processed, otherwise false.
+    */
+    resolveTile: function (x, y, body, tile) {
+
+        if (0 < tile.id)
+        {
+            return this.aabbTileProjections[tile.type](x, y, body, tile);
+        }
+        else
+        {
+            // console.warn("Ninja.AABB.resolveTile was called with an empty (or unknown) tile!: id=" + tile.id + ")");
+            return false;
+        }
+
+    },
+
+    /**
+    * Resolves Full tile collision.
+    *
+    * @method Phaser.Physics.Ninja.AABB#projAABB_Full
+    * @param {number} x - Penetration depth on the x axis.
+    * @param {number} y - Penetration depth on the y axis.
+    * @param {Phaser.Physics.Ninja.AABB} obj - The AABB involved in the collision.
+    * @param {Phaser.Physics.Ninja.Tile} t - The Tile involved in the collision.
+    * @return {number} The result of the collision.
+    */
+    projAABB_Full: function (x, y, obj, t) {
+
+        var l = Math.sqrt(x * x + y * y);
+        obj.reportCollisionVsWorld(x, y, x / l, y / l, t);
+
+        return Phaser.Physics.Ninja.AABB.COL_AXIS;
+
+    },
+
+    /**
+    * Resolves Half tile collision.
+    *
+    * @method Phaser.Physics.Ninja.AABB#projAABB_Half
+    * @param {number} x - Penetration depth on the x axis.
+    * @param {number} y - Penetration depth on the y axis.
+    * @param {Phaser.Physics.Ninja.AABB} obj - The AABB involved in the collision.
+    * @param {Phaser.Physics.Ninja.Tile} t - The Tile involved in the collision.
+    * @return {number} The result of the collision.
+    */
+    projAABB_Half: function (x, y, obj, t) {
+
+        //signx or signy must be 0; the other must be -1 or 1
+        //calculate the projection vector for the half-edge, and then 
+        //(if collision is occuring) pick the minimum
+        
+        var sx = t.signx;
+        var sy = t.signy;
+            
+        var ox = (obj.pos.x - (sx*obj.xw)) - t.pos.x;//this gives is the coordinates of the innermost
+        var oy = (obj.pos.y - (sy*obj.yw)) - t.pos.y;//point on the AABB, relative to the tile center
+
+        //we perform operations analogous to the 45deg tile, except we're using 
+        //an axis-aligned slope instead of an angled one..
+
+        //if the dotprod of (ox,oy) and (sx,sy) is negative, the corner is in the slope
+        //and we need toproject it out by the magnitude of the projection of (ox,oy) onto (sx,sy)
+        var dp = (ox*sx) + (oy*sy);
+
+        if (dp < 0)
+        {
+            //collision; project delta onto slope and use this to displace the object
+            sx *= -dp;//(sx,sy) is now the projection vector
+            sy *= -dp;      
+                
+            var lenN = Math.sqrt(sx*sx + sy*sy);
+            var lenP = Math.sqrt(x*x + y*y);
+            
+            if (lenP < lenN)
+            {
+                //project along axis; note that we're assuming that this tile is horizontal OR vertical
+                //relative to the AABB's current tile, and not diagonal OR the current tile.
+                obj.reportCollisionVsWorld(x,y,x/lenP, y/lenP, t);
+
+                return Phaser.Physics.Ninja.AABB.COL_AXIS;
+            }
+            else
+            {       
+                //note that we could use -= instead of -dp
+                obj.reportCollisionVsWorld(sx,sy,t.signx, t.signy, t);
+                    
+                return Phaser.Physics.Ninja.AABB.COL_OTHER;
+            }
+        }
+            
+        return Phaser.Physics.Ninja.AABB.COL_NONE;
+
+    },
+
+    /**
+    * Resolves 45 Degree tile collision.
+    *
+    * @method Phaser.Physics.Ninja.AABB#projAABB_45Deg
+    * @param {number} x - Penetration depth on the x axis.
+    * @param {number} y - Penetration depth on the y axis.
+    * @param {Phaser.Physics.Ninja.AABB} obj - The AABB involved in the collision.
+    * @param {Phaser.Physics.Ninja.Tile} t - The Tile involved in the collision.
+    * @return {number} The result of the collision.
+    */
+    projAABB_45Deg: function (x, y, obj, t) {
+
+        var signx = t.signx;
+        var signy = t.signy;
+
+        var ox = (obj.pos.x - (signx*obj.xw)) - t.pos.x;//this gives is the coordinates of the innermost
+        var oy = (obj.pos.y - (signy*obj.yw)) - t.pos.y;//point on the AABB, relative to the tile center
+
+        var sx = t.sx;
+        var sy = t.sy;
+            
+        //if the dotprod of (ox,oy) and (sx,sy) is negative, the corner is in the slope
+        //and we need toproject it out by the magnitude of the projection of (ox,oy) onto (sx,sy)
+        var dp = (ox*sx) + (oy*sy);
+
+        if (dp < 0)
+        {
+            //collision; project delta onto slope and use this to displace the object
+            sx *= -dp;//(sx,sy) is now the projection vector
+            sy *= -dp;      
+            
+            var lenN = Math.sqrt(sx*sx + sy*sy);
+            var lenP = Math.sqrt(x*x + y*y);
+
+            if (lenP < lenN)
+            {
+                //project along axis
+                obj.reportCollisionVsWorld(x,y,x/lenP, y/lenP, t);
+
+                return Phaser.Physics.Ninja.AABB.COL_AXIS;
+            }
+            else
+            {
+                //project along slope
+                obj.reportCollisionVsWorld(sx,sy,t.sx,t.sy);
+
+                return Phaser.Physics.Ninja.AABB.COL_OTHER;
+            }
+        }
+        
+        return Phaser.Physics.Ninja.AABB.COL_NONE;
+    },
+
+    /**
+    * Resolves 22 Degree tile collision.
+    *
+    * @method Phaser.Physics.Ninja.AABB#projAABB_22DegS
+    * @param {number} x - Penetration depth on the x axis.
+    * @param {number} y - Penetration depth on the y axis.
+    * @param {Phaser.Physics.Ninja.AABB} obj - The AABB involved in the collision.
+    * @param {Phaser.Physics.Ninja.Tile} t - The Tile involved in the collision.
+    * @return {number} The result of the collision.
+    */
+    projAABB_22DegS: function (x, y, obj, t) {
+        
+        var signx = t.signx;
+        var signy = t.signy;
+
+        //first we need to check to make sure we're colliding with the slope at all
+        var py = obj.pos.y - (signy*obj.yw);
+        var penY = t.pos.y - py;//this is the vector from the innermost point on the box to the highest point on
+                                //the tile; if it is positive, this means the box is above the tile and
+                                //no collision is occuring
+        if (0 < (penY*signy))
+        {
+            var ox = (obj.pos.x - (signx*obj.xw)) - (t.pos.x + (signx*t.xw));//this gives is the coordinates of the innermost
+            var oy = (obj.pos.y - (signy*obj.yw)) - (t.pos.y - (signy*t.yw));//point on the AABB, relative to a point on the slope
+                                                        
+            var sx = t.sx;//get slope unit normal
+            var sy = t.sy;
+            
+            //if the dotprod of (ox,oy) and (sx,sy) is negative, the corner is in the slope
+            //and we need toproject it out by the magnitude of the projection of (ox,oy) onto (sx,sy)
+            var dp = (ox*sx) + (oy*sy);
+
+            if (dp < 0)
+            {
+                //collision; project delta onto slope and use this to displace the object
+                sx *= -dp;//(sx,sy) is now the projection vector
+                sy *= -dp;      
+
+                var lenN = Math.sqrt(sx*sx + sy*sy);
+                var lenP = Math.sqrt(x*x + y*y);
+                
+                var aY = Math.abs(penY);
+
+                if (lenP < lenN)
+                {
+                    if (aY < lenP)
+                    {
+                        obj.reportCollisionVsWorld(0, penY, 0, penY/aY, t);
+                        
+                        return Phaser.Physics.Ninja.AABB.COL_OTHER;
+                    }
+                    else
+                    {
+                        obj.reportCollisionVsWorld(x,y,x/lenP, y/lenP, t);
+                        
+                        return Phaser.Physics.Ninja.AABB.COL_AXIS;
+                    }
+                }
+                else
+                {
+                    if (aY < lenN)
+                    {
+                        obj.reportCollisionVsWorld(0, penY, 0, penY/aY, t);
+                        
+                        return Phaser.Physics.Ninja.AABB.COL_OTHER;
+                    }
+                    else
+                    {
+                        obj.reportCollisionVsWorld(sx,sy,t.sx,t.sy,t);
+
+                        return Phaser.Physics.Ninja.AABB.COL_OTHER;
+                    }
+                }
+            }
+        }
+        
+        //if we've reached this point, no collision has occured
+        return Phaser.Physics.Ninja.AABB.COL_NONE;
+    },
+
+    /**
+    * Resolves 22 Degree tile collision.
+    *
+    * @method Phaser.Physics.Ninja.AABB#projAABB_22DegB
+    * @param {number} x - Penetration depth on the x axis.
+    * @param {number} y - Penetration depth on the y axis.
+    * @param {Phaser.Physics.Ninja.AABB} obj - The AABB involved in the collision.
+    * @param {Phaser.Physics.Ninja.Tile} t - The Tile involved in the collision.
+    * @return {number} The result of the collision.
+    */
+    projAABB_22DegB: function (x, y, obj, t) {
+
+        var signx = t.signx;
+        var signy = t.signy;
+
+        var ox = (obj.pos.x - (signx*obj.xw)) - (t.pos.x - (signx*t.xw));//this gives is the coordinates of the innermost
+        var oy = (obj.pos.y - (signy*obj.yw)) - (t.pos.y + (signy*t.yw));//point on the AABB, relative to a point on the slope
+            
+        var sx = t.sx;//get slope unit normal
+        var sy = t.sy;
+            
+        //if the dotprod of (ox,oy) and (sx,sy) is negative, the corner is in the slope
+        //and we need toproject it out by the magnitude of the projection of (ox,oy) onto (sx,sy)
+        var dp = (ox*sx) + (oy*sy);
+
+        if (dp < 0)
+        {
+            //collision; project delta onto slope and use this to displace the object
+            sx *= -dp;//(sx,sy) is now the projection vector
+            sy *= -dp;      
+
+            var lenN = Math.sqrt(sx*sx + sy*sy);
+            var lenP = Math.sqrt(x*x + y*y);
+
+            if (lenP < lenN)
+            {
+                obj.reportCollisionVsWorld(x,y,x/lenP, y/lenP, t);
+                    
+                return Phaser.Physics.Ninja.AABB.COL_AXIS;
+            }
+            else
+            {       
+                obj.reportCollisionVsWorld(sx,sy,t.sx,t.sy,t);
+                                    
+                return Phaser.Physics.Ninja.AABB.COL_OTHER;
+            }
+        
+        }
+            
+        return Phaser.Physics.Ninja.AABB.COL_NONE;
+
+    },
+
+    /**
+    * Resolves 67 Degree tile collision.
+    *
+    * @method Phaser.Physics.Ninja.AABB#projAABB_67DegS
+    * @param {number} x - Penetration depth on the x axis.
+    * @param {number} y - Penetration depth on the y axis.
+    * @param {Phaser.Physics.Ninja.AABB} obj - The AABB involved in the collision.
+    * @param {Phaser.Physics.Ninja.Tile} t - The Tile involved in the collision.
+    * @return {number} The result of the collision.
+    */
+    projAABB_67DegS: function (x, y, obj, t) {
+
+        var signx = t.signx;
+        var signy = t.signy;
+
+        var px = obj.pos.x - (signx*obj.xw);
+        var penX = t.pos.x - px;
+
+        if (0 < (penX*signx))
+        {
+            var ox = (obj.pos.x - (signx*obj.xw)) - (t.pos.x - (signx*t.xw));//this gives is the coordinates of the innermost
+            var oy = (obj.pos.y - (signy*obj.yw)) - (t.pos.y + (signy*t.yw));//point on the AABB, relative to a point on the slope
+
+            var sx = t.sx;//get slope unit normal
+            var sy = t.sy;
+            
+            //if the dotprod of (ox,oy) and (sx,sy) is negative, the corner is in the slope
+            //and we need to project it out by the magnitude of the projection of (ox,oy) onto (sx,sy)
+            var dp = (ox*sx) + (oy*sy);
+
+            if (dp < 0)
+            {
+                //collision; project delta onto slope and use this to displace the object
+                sx *= -dp;//(sx,sy) is now the projection vector
+                sy *= -dp;      
+
+                var lenN = Math.sqrt(sx*sx + sy*sy);
+                var lenP = Math.sqrt(x*x + y*y);
+
+                var aX = Math.abs(penX);
+
+                if (lenP < lenN)
+                {
+                    if (aX < lenP)
+                    {
+                        obj.reportCollisionVsWorld(penX, 0, penX/aX, 0, t);
+                        
+                        return Phaser.Physics.Ninja.AABB.COL_OTHER;
+                    }
+                    else
+                    {
+                        obj.reportCollisionVsWorld(x,y,x/lenP, y/lenP, t);
+                        
+                        return Phaser.Physics.Ninja.AABB.COL_AXIS;
+                    }
+                }
+                else
+                {
+                    if (aX < lenN)
+                    {
+                        obj.reportCollisionVsWorld(penX, 0, penX/aX, 0, t);
+                        
+                        return Phaser.Physics.Ninja.AABB.COL_OTHER;
+                    }
+                    else
+                    {               
+                        obj.reportCollisionVsWorld(sx,sy,t.sx,t.sy,t);
+
+                        return Phaser.Physics.Ninja.AABB.COL_OTHER;
+                    }
+                }
+            }
+        }
+        
+        //if we've reached this point, no collision has occured
+        return Phaser.Physics.Ninja.AABB.COL_NONE;    
+
+    },
+
+    /**
+    * Resolves 67 Degree tile collision.
+    *
+    * @method Phaser.Physics.Ninja.AABB#projAABB_67DegB
+    * @param {number} x - Penetration depth on the x axis.
+    * @param {number} y - Penetration depth on the y axis.
+    * @param {Phaser.Physics.Ninja.AABB} obj - The AABB involved in the collision.
+    * @param {Phaser.Physics.Ninja.Tile} t - The Tile involved in the collision.
+    * @return {number} The result of the collision.
+    */
+    projAABB_67DegB: function (x, y, obj, t) {
+
+        var signx = t.signx;
+        var signy = t.signy;
+            
+        var ox = (obj.pos.x - (signx*obj.xw)) - (t.pos.x + (signx*t.xw));//this gives is the coordinates of the innermost
+        var oy = (obj.pos.y - (signy*obj.yw)) - (t.pos.y - (signy*t.yw));//point on the AABB, relative to a point on the slope
+                                                        
+        var sx = t.sx;//get slope unit normal
+        var sy = t.sy;
+            
+        //if the dotprod of (ox,oy) and (sx,sy) is negative, the corner is in the slope
+        //and we need toproject it out by the magnitude of the projection of (ox,oy) onto (sx,sy)
+        var dp = (ox*sx) + (oy*sy);
+
+        if (dp < 0)
+        {
+            //collision; project delta onto slope and use this to displace the object
+            sx *= -dp;//(sx,sy) is now the projection vector
+            sy *= -dp;      
+                
+            var lenN = Math.sqrt(sx*sx + sy*sy);
+            var lenP = Math.sqrt(x*x + y*y);
+                
+            if (lenP < lenN)
+            {
+                obj.reportCollisionVsWorld(x,y,x/lenP, y/lenP, t);
+
+                return Phaser.Physics.Ninja.AABB.COL_AXIS;
+            }
+            else
+            {       
+                obj.reportCollisionVsWorld(sx,sy,t.sx,t.sy,t);
+                    
+                return Phaser.Physics.Ninja.AABB.COL_OTHER;
+            }
+        }
+            
+        return Phaser.Physics.Ninja.AABB.COL_NONE;    
+    },
+
+    /**
+    * Resolves Convex tile collision.
+    *
+    * @method Phaser.Physics.Ninja.AABB#projAABB_Convex
+    * @param {number} x - Penetration depth on the x axis.
+    * @param {number} y - Penetration depth on the y axis.
+    * @param {Phaser.Physics.Ninja.AABB} obj - The AABB involved in the collision.
+    * @param {Phaser.Physics.Ninja.Tile} t - The Tile involved in the collision.
+    * @return {number} The result of the collision.
+    */
+    projAABB_Convex: function (x, y, obj, t) {
+
+        //if distance from "innermost" corner of AABB is less than than tile radius,
+        //collision is occuring and we need to project
+
+        var signx = t.signx;
+        var signy = t.signy;
+
+        var ox = (obj.pos.x - (signx * obj.xw)) - (t.pos.x - (signx * t.xw));//(ox,oy) is the vector from the circle center to
+        var oy = (obj.pos.y - (signy * obj.yw)) - (t.pos.y - (signy * t.yw));//the AABB
+        var len = Math.sqrt(ox * ox + oy * oy);
+
+        var twid = t.xw * 2;
+        var rad = Math.sqrt(twid * twid + 0);//this gives us the radius of a circle centered on the tile's corner and extending to the opposite edge of the tile;
+        //note that this should be precomputed at compile-time since it's constant
+
+        var pen = rad - len;
+
+        if (((signx * ox) < 0) || ((signy * oy) < 0))
+        {
+            //the test corner is "outside" the 1/4 of the circle we're interested in
+            var lenP = Math.sqrt(x * x + y * y);
+            obj.reportCollisionVsWorld(x, y, x / lenP, y / lenP, t);
+
+            return Phaser.Physics.Ninja.AABB.COL_AXIS;//we need to report 		
+        }
+        else if (0 < pen)
+        {
+            //project along corner->circle vector
+            ox /= len;
+            oy /= len;
+            obj.reportCollisionVsWorld(ox * pen, oy * pen, ox, oy, t);
+
+            return Phaser.Physics.Ninja.AABB.COL_OTHER;
+        }
+
+        return Phaser.Physics.Ninja.AABB.COL_NONE;
+
+    },
+
+    /**
+    * Resolves Concave tile collision.
+    *
+    * @method Phaser.Physics.Ninja.AABB#projAABB_Concave
+    * @param {number} x - Penetration depth on the x axis.
+    * @param {number} y - Penetration depth on the y axis.
+    * @param {Phaser.Physics.Ninja.AABB} obj - The AABB involved in the collision.
+    * @param {Phaser.Physics.Ninja.Tile} t - The Tile involved in the collision.
+    * @return {number} The result of the collision.
+    */
+    projAABB_Concave: function (x, y, obj, t) {
+
+        //if distance from "innermost" corner of AABB is further than tile radius,
+        //collision is occuring and we need to project
+
+        var signx = t.signx;
+        var signy = t.signy;
+
+        var ox = (t.pos.x + (signx * t.xw)) - (obj.pos.x - (signx * obj.xw));//(ox,oy) is the vector form the innermost AABB corner to the
+        var oy = (t.pos.y + (signy * t.yw)) - (obj.pos.y - (signy * obj.yw));//circle's center
+
+        var twid = t.xw * 2;
+        var rad = Math.sqrt(twid * twid + 0);//this gives us the radius of a circle centered on the tile's corner and extending to the opposite edge of the tile;
+        //note that this should be precomputed at compile-time since it's constant
+
+        var len = Math.sqrt(ox * ox + oy * oy);
+        var pen = len - rad;
+
+        if (0 < pen)
+        {
+            //collision; we need to either project along the axes, or project along corner->circlecenter vector
+
+            var lenP = Math.sqrt(x * x + y * y);
+
+            if (lenP < pen)
+            {
+                //it's shorter to move along axis directions
+                obj.reportCollisionVsWorld(x, y, x / lenP, y / lenP, t);
+
+                return Phaser.Physics.Ninja.AABB.COL_AXIS;
+            }
+            else
+            {
+                //project along corner->circle vector
+                ox /= len;//len should never be 0, since if it IS 0, rad should be > than len
+                oy /= len;//and we should never reach here
+
+                obj.reportCollisionVsWorld(ox * pen, oy * pen, ox, oy, t);
+
+                return Phaser.Physics.Ninja.AABB.COL_OTHER;
+            }
+
+        }
+
+        return Phaser.Physics.Ninja.AABB.COL_NONE;
+		
+    }
+
+}
+
+
+
+ + + + + +
+ +
+
+ + + + Phaser Copyright © 2012-2014 Photon Storm Ltd. + +
+ + + Documentation generated by JSDoc 3.3.0-dev + on Fri Mar 14 2014 06:34:18 GMT-0000 (GMT) using the DocStrap template. + +
+
+ + +
+
+ +
+ + + + + + + + + + + + + + + + + + + + diff --git a/docs/Animation.js.html b/docs/Animation.js.html index 543fb05f29..c687d710ef 100644 --- a/docs/Animation.js.html +++ b/docs/Animation.js.html @@ -58,10 +58,6 @@ BitmapData -
  • - BitmapFont -
  • -
  • BitmapText
  • @@ -259,35 +255,83 @@
  • - Body + Body +
  • + +
  • + Ninja +
  • + +
  • + AABB +
  • + +
  • + Body +
  • + +
  • + Circle +
  • + +
  • + Tile +
  • + +
  • + P2 +
  • + +
  • + Body +
  • + +
  • + BodyDebug +
  • + +
  • + CollisionGroup +
  • + +
  • + ContactMaterial +
  • + +
  • + DistanceConstraint
  • - CollisionGroup + GearConstraint
  • - ContactMaterial + InversePointProxy
  • - InversePointProxy + LockConstraint
  • - Material + Material
  • - PointProxy + PointProxy
  • - Spring + PrismaticConstraint
  • - World + RevoluteConstraint +
  • + +
  • + Spring
  • @@ -310,6 +354,10 @@ Polygon
  • +
  • + QuadTree +
  • +
  • RandomDataGenerator
  • @@ -326,6 +374,14 @@ RequestAnimationFrame +
  • + RetroFont +
  • + +
  • + ScaleManager +
  • +
  • Signal
  • @@ -354,10 +410,6 @@ Stage -
  • - StageScaleMode -
  • -
  • State
  • @@ -438,40 +490,6 @@ - - @@ -507,9 +525,9 @@

    Source: animation/Animation.js

    * @param {Phaser.FrameData} frameData - The FrameData object that contains all frames used by this Animation. * @param {(Array.<number>|Array.<string>)} frames - An array of numbers or strings indicating which frames to play in which order. * @param {number} delay - The time between each frame of the animation, given in ms. -* @param {boolean} looped - Should this animation loop or play through once. +* @param {boolean} loop - Should this animation loop when it reaches the end or play through once. */ -Phaser.Animation = function (game, parent, name, frameData, frames, delay, looped) { +Phaser.Animation = function (game, parent, name, frameData, frames, delay, loop) { /** * @property {Phaser.Game} game - A reference to the currently running Game. @@ -546,9 +564,14 @@

    Source: animation/Animation.js

    this.delay = 1000 / delay; /** - * @property {boolean} looped - The loop state of the Animation. + * @property {boolean} loop - The loop state of the Animation. + */ + this.loop = loop; + + /** + * @property {number} loopCount - The number of times the animation has looped since it was last started. */ - this.looped = looped; + this.loopCount = 0; /** * @property {boolean} killOnComplete - Should the parent of this Animation be killed when the animation completes? @@ -606,6 +629,25 @@

    Source: animation/Animation.js

    * @property {Phaser.Frame} currentFrame - The currently displayed frame of the Animation. */ this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]); + + /** + * @property {Phaser.Signal} onStart - This event is dispatched when this Animation starts playback. + */ + this.onStart = new Phaser.Signal(); + + /** + * @property {Phaser.Signal} onComplete - This event is dispatched when this Animation completes playback. If the animation is set to loop this is never fired, listen for onAnimationLoop instead. + */ + this.onComplete = new Phaser.Signal(); + + /** + * @property {Phaser.Signal} onLoop - This event is dispatched when this Animation loops. + */ + this.onLoop = new Phaser.Signal(); + + // Set-up some event listeners + this.game.onPause.add(this.onPause, this); + this.game.onResume.add(this.onResume, this); }; @@ -632,7 +674,7 @@

    Source: animation/Animation.js

    if (typeof loop === 'boolean') { // If they set a new loop value then use it, otherwise use the one set on creation - this.looped = loop; + this.loop = loop; } if (typeof killOnComplete !== 'undefined') @@ -644,6 +686,7 @@

    Source: animation/Animation.js

    this.isPlaying = true; this.isFinished = false; this.paused = false; + this.loopCount = 0; this._timeLastFrame = this.game.time.now; this._timeNextFrame = this.game.time.now + this.delay; @@ -653,16 +696,15 @@

    Source: animation/Animation.js

    this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]); this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid]); + // TODO: Double check if required if (this._parent.__tilePattern) { this._parent.__tilePattern = false; this._parent.tilingTexture = false; } - if (this._parent.events) - { - this._parent.events.onAnimationStart.dispatch(this._parent, this); - } + this._parent.events.onAnimationStart.dispatch(this._parent, this); + this.onStart.dispatch(this._parent, this); return this; @@ -679,6 +721,7 @@

    Source: animation/Animation.js

    this.isPlaying = true; this.isFinished = false; this.paused = false; + this.loopCount = 0; this._timeLastFrame = this.game.time.now; this._timeNextFrame = this.game.time.now + this.delay; @@ -687,18 +730,23 @@

    Source: animation/Animation.js

    this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]); + this.onStart.dispatch(this._parent, this); + }, /** * Stops playback of this animation and set it to a finished state. If a resetFrame is provided it will stop playback and set frame to the first in the animation. + * If `dispatchComplete` is true it will dispatch the complete events, otherwise they'll be ignored. * * @method Phaser.Animation#stop * @memberof Phaser.Animation * @param {boolean} [resetFrame=false] - If true after the animation stops the currentFrame value will be set to the first frame in this animation. + * @param {boolean} [dispatchComplete=false] - Dispatch the Animation.onComplete and parent.onAnimationComplete events? */ - stop: function (resetFrame) { + stop: function (resetFrame, dispatchComplete) { if (typeof resetFrame === 'undefined') { resetFrame = false; } + if (typeof dispatchComplete === 'undefined') { dispatchComplete = false; } this.isPlaying = false; this.isFinished = true; @@ -709,6 +757,42 @@

    Source: animation/Animation.js

    this.currentFrame = this._frameData.getFrame(this._frames[0]); } + if (dispatchComplete) + { + this._parent.events.onAnimationComplete.dispatch(this._parent, this); + this.onComplete.dispatch(this._parent, this); + } + + }, + + /** + * Called when the Game enters a paused state. + * + * @method Phaser.Animation#onPause + * @memberof Phaser.Animation + */ + onPause: function () { + + if (this.isPlaying) + { + this._frameDiff = this._timeNextFrame - this.game.time.now; + } + + }, + + /** + * Called when the Game resumes from a paused state. + * + * @method Phaser.Animation#onResume + * @memberof Phaser.Animation + */ + onResume: function () { + + if (this.isPlaying) + { + this._timeNextFrame = this.game.time.now + this._frameDiff; + } + }, /** @@ -748,7 +832,7 @@

    Source: animation/Animation.js

    if (this._frameIndex >= this._frames.length) { - if (this.looped) + if (this.loop) { this._frameIndex %= this._frames.length; this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]); @@ -764,11 +848,13 @@

    Source: animation/Animation.js

    } } + this.loopCount++; this._parent.events.onAnimationLoop.dispatch(this._parent, this); + this.onLoop.dispatch(this._parent, this); } else { - this.onComplete(); + this.complete(); } } else @@ -809,24 +895,31 @@

    Source: animation/Animation.js

    this.currentFrame = null; this.isPlaying = false; + this.onStart.destroy(); + this.onLoop.destroy(); + this.onComplete.destroy(); + + this.game.onPause.remove(this.onPause, this); + this.game.onResume.remove(this.onResume, this); + }, /** - * Called internally when the animation finishes playback. Sets the isPlaying and isFinished states and dispatches the onAnimationComplete event if it exists on the parent. + * Called internally when the animation finishes playback. + * Sets the isPlaying and isFinished states and dispatches the onAnimationComplete event if it exists on the parent and local onComplete event. * - * @method Phaser.Animation#onComplete + * @method Phaser.Animation#complete * @memberof Phaser.Animation */ - onComplete: function () { + complete: function () { this.isPlaying = false; this.isFinished = true; this.paused = false; - if (this._parent.events) - { - this._parent.events.onAnimationComplete.dispatch(this._parent, this); - } + this._parent.events.onAnimationComplete.dispatch(this._parent, this); + + this.onComplete.dispatch(this._parent, this); if (this.killOnComplete) { @@ -919,6 +1012,29 @@

    Source: animation/Animation.js

    }); +/** +* @name Phaser.Animation#speed +* @property {number} speed - Gets or sets the current speed of the animation, the time between each frame of the animation, given in ms. Takes effect from the NEXT frame. Minimum value is 1. +*/ +Object.defineProperty(Phaser.Animation.prototype, 'speed', { + + get: function () { + + return Math.round(1000 / this.delay); + + }, + + set: function (value) { + + if (value >= 1) + { + this.delay = 1000 / value; + } + + } + +}); + /** * Really handy function for when you are creating arrays of animation data but it's using frame names and not numbers. * For example imagine you've got 30 frames named: 'explosion_0001-large' to 'explosion_0030-large' @@ -1001,7 +1117,7 @@

    Source: animation/Animation.js

    Documentation generated by JSDoc 3.3.0-dev - on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template. + on Fri Mar 14 2014 06:34:17 GMT-0000 (GMT) using the DocStrap template. @@ -1028,6 +1144,9 @@

    Source: animation/Animation.js

    - - - - - - - - - - - - - - - - - - - diff --git a/docs/BitmapData.js.html b/docs/BitmapData.js.html index 1dfe066031..52527e9874 100644 --- a/docs/BitmapData.js.html +++ b/docs/BitmapData.js.html @@ -58,10 +58,6 @@ BitmapData -
  • - BitmapFont -
  • -
  • BitmapText
  • @@ -259,35 +255,83 @@
  • - Body + Body +
  • + +
  • + Ninja +
  • + +
  • + AABB +
  • + +
  • + Body +
  • + +
  • + Circle +
  • + +
  • + Tile +
  • + +
  • + P2 +
  • + +
  • + Body +
  • + +
  • + BodyDebug +
  • + +
  • + CollisionGroup +
  • + +
  • + ContactMaterial +
  • + +
  • + DistanceConstraint +
  • + +
  • + GearConstraint
  • - CollisionGroup + InversePointProxy
  • - ContactMaterial + LockConstraint
  • - InversePointProxy + Material
  • - Material + PointProxy
  • - PointProxy + PrismaticConstraint
  • - Spring + RevoluteConstraint
  • - World + Spring
  • @@ -310,6 +354,10 @@ Polygon
  • +
  • + QuadTree +
  • +
  • RandomDataGenerator
  • @@ -326,6 +374,14 @@ RequestAnimationFrame +
  • + RetroFont +
  • + +
  • + ScaleManager +
  • +
  • Signal
  • @@ -354,10 +410,6 @@ Stage -
  • - StageScaleMode -
  • -
  • State
  • @@ -438,40 +490,6 @@ - - @@ -538,7 +556,7 @@

    Source: gameobjects/BitmapData.js

    * @property {HTMLCanvasElement} canvas - The canvas to which this BitmapData draws. * @default */ - this.canvas = Phaser.Canvas.create(width, height); + this.canvas = Phaser.Canvas.create(width, height, '', true); /** * @property {CanvasRenderingContext2D} context - The 2d context of the canvas. @@ -643,7 +661,6 @@

    Source: gameobjects/BitmapData.js

    if (width !== this.width || height !== this.height) { - console.log('bmd resize', width, height); this.width = width; this.height = height; this.canvas.width = width; @@ -858,7 +875,8 @@

    Source: gameobjects/BitmapData.js

    // Only needed if running in WebGL, otherwise this array will never get cleared down if (this.game.renderType === Phaser.WEBGL) { - PIXI.texturesToUpdate.push(this.baseTexture); + // should use the rendersession + PIXI.updateWebGLTexture(this.baseTexture, this.game.renderer.gl); } this._dirty = false; @@ -890,7 +908,7 @@

    Source: gameobjects/BitmapData.js

    Documentation generated by JSDoc 3.3.0-dev - on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template. + on Fri Mar 14 2014 06:34:17 GMT-0000 (GMT) using the DocStrap template. @@ -917,6 +935,9 @@

    Source: gameobjects/BitmapData.js

    + + + + + + + + + + + + + + + + + + + diff --git a/docs/Body.js__.html b/docs/Body.js__.html new file mode 100644 index 0000000000..61c859218b --- /dev/null +++ b/docs/Body.js__.html @@ -0,0 +1,2244 @@ + + + + + + Phaser Source: physics/p2/Body.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: physics/p2/Body.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2014 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* The Physics Body is typically linked to a single Sprite and defines properties that determine how the physics body is simulated.
    +* These properties affect how the body reacts to forces, what forces it generates on itself (to simulate friction), and how it reacts to collisions in the scene.
    +* In most cases, the properties are used to simulate physical effects. Each body also has its own property values that determine exactly how it reacts to forces and collisions in the scene.
    +* By default a single Rectangle shape is added to the Body that matches the dimensions of the parent Sprite. See addShape, removeShape, clearShapes to add extra shapes around the Body.
    +* Note: When bound to a Sprite to avoid single-pixel jitters on mobile devices we strongly recommend using Sprite sizes that are even on both axis, i.e. 128x128 not 127x127.
    +*
    +* @class Phaser.Physics.P2.Body
    +* @classdesc Physics Body Constructor
    +* @constructor
    +* @param {Phaser.Game} game - Game reference to the currently running game.
    +* @param {Phaser.Sprite} [sprite] - The Sprite object this physics body belongs to.
    +* @param {number} [x=0] - The x coordinate of this Body.
    +* @param {number} [y=0] - The y coordinate of this Body.
    +* @param {number} [mass=1] - The default mass of this Body (0 = static).
    +*/
    +Phaser.Physics.P2.Body = function (game, sprite, x, y, mass) {
    +
    +    sprite = sprite || null;
    +    x = x || 0;
    +    y = y || 0;
    +    if (typeof mass === 'undefined') { mass = 1; }
    +
    +    /**
    +    * @property {Phaser.Game} game - Local reference to game.
    +    */
    +    this.game = game;
    +
    +    /**
    +    * @property {Phaser.Physics.P2} world - Local reference to the P2 World.
    +    */
    +    this.world = game.physics.p2;
    +
    +    /**
    +    * @property {Phaser.Sprite} sprite - Reference to the parent Sprite.
    +    */
    +    this.sprite = sprite;
    +
    +    /**
    +    * @property {number} type - The type of physics system this body belongs to.
    +    */
    +    this.type = Phaser.Physics.P2JS;
    +
    +    /**
    +    * @property {Phaser.Point} offset - The offset of the Physics Body from the Sprite x/y position.
    +    */
    +    this.offset = new Phaser.Point();
    +
    +    /**
    +    * @property {p2.Body} data - The p2 Body data.
    +    * @protected
    +    */
    +    this.data = new p2.Body({ position: [ this.world.pxmi(x), this.world.pxmi(y) ], mass: mass });
    +    this.data.parent = this;
    +
    +    /**
    +    * @property {Phaser.InversePointProxy} velocity - The velocity of the body. Set velocity.x to a negative value to move to the left, position to the right. velocity.y negative values move up, positive move down.
    +    */
    +    this.velocity = new Phaser.Physics.P2.InversePointProxy(this.world, this.data.velocity);
    +
    +    /**
    +    * @property {Phaser.InversePointProxy} force - The force applied to the body.
    +    */
    +    this.force = new Phaser.Physics.P2.InversePointProxy(this.world, this.data.force);
    +
    +    /**
    +    * @property {Phaser.Point} gravity - A locally applied gravity force to the Body. Applied directly before the world step. NOTE: Not currently implemented.
    +    */
    +    this.gravity = new Phaser.Point();
    +
    +    /**
    +    * Dispatched when the shape/s of this Body impact with another. The event will be sent 2 parameters, this Body and the impact Body.
    +    * @property {Phaser.Signal} onImpact
    +    */
    +    this.onImpact = new Phaser.Signal();
    +
    +    /**
    +    * Dispatched when a first contact is created between shapes in two bodies. This event is fired during the step, so collision has already taken place.
    +    * The event will be sent 4 parameters: The body it is in contact with, the shape from this body that caused the contact, the shape from the contact body and the contact equation data array.
    +    * @property {Phaser.Signal} onBeginContact
    +    */
    +    this.onBeginContact = new Phaser.Signal();
    +
    +    /**
    +    * Dispatched when contact ends between shapes in two bodies. This event is fired during the step, so collision has already taken place.
    +    * The event will be sent 3 parameters: The body it is in contact with, the shape from this body that caused the contact and the shape from the contact body.
    +    * @property {Phaser.Signal} onEndContact
    +    */
    +    this.onEndContact = new Phaser.Signal();
    +
    +    /**
    +    * @property {array} collidesWith - Array of CollisionGroups that this Bodies shapes collide with.
    +    * @private
    +    */
    +    this.collidesWith = [];
    +
    +    /**
    +    * @property {boolean} removeNextStep - To avoid deleting this body during a physics step, and causing all kinds of problems, set removeNextStep to true to have it removed in the next preUpdate.
    +    */
    +    this.removeNextStep = false;
    +
    +    this._collideWorldBounds = true;
    +
    +    /**
    +    * @property {object} _bodyCallbacks - Array of Body callbacks.
    +    * @private
    +    */
    +    this._bodyCallbacks = {};
    +
    +    /**
    +    * @property {object} _bodyCallbackContext - Array of Body callback contexts.
    +    * @private
    +    */
    +    this._bodyCallbackContext = {};
    +
    +    /**
    +    * @property {object} _groupCallbacks - Array of Group callbacks.
    +    * @private
    +    */
    +    this._groupCallbacks = {};
    +
    +    /**
    +    * @property {object} _bodyCallbackContext - Array of Grouo callback contexts.
    +    * @private
    +    */
    +    this._groupCallbackContext = {};
    +
    +    /**
    +    * @property {Phaser.Physics.P2.BodyDebug} debugBody - Reference to the debug body.
    +    */
    +    this.debugBody = null
    +
    +    //  Set-up the default shape
    +    if (sprite)
    +    {
    +        this.setRectangleFromSprite(sprite);
    +
    +        this.game.physics.p2.addBody(this);
    +    }
    +
    +};
    +
    +Phaser.Physics.P2.Body.prototype = {
    +
    +    /**
    +    * Sets a callback to be fired any time a shape in this Body impacts with a shape in the given Body. The impact test is performed against body.id values.
    +    * The callback will be sent 4 parameters: This body, the body that impacted, the Shape in this body and the shape in the impacting body.
    +    * Note that the impact event happens after collision resolution, so it cannot be used to prevent a collision from happening.
    +    * It also happens mid-step. So do not destroy a Body during this callback, instead set safeDestroy to true so it will be killed on the next preUpdate.
    +    *
    +    * @method Phaser.Physics.P2.Body#createBodyCallback
    +    * @param {Phaser.Sprite|Phaser.TileSprite|Phaser.Physics.P2.Body|p2.Body} object - The object to send impact events for.
    +    * @param {function} callback - The callback to fire on impact. Set to null to clear a previously set callback.
    +    * @param {object} callbackContext - The context under which the callback will fire.
    +    */
    +    createBodyCallback: function (object, callback, callbackContext) {
    +
    +        var id = -1;
    +
    +        if (object['id'])
    +        {
    +            id = object.id;
    +        }
    +        else if (object['body'])
    +        {
    +            id = object.body.id;
    +        }
    +
    +        if (id > -1)
    +        {
    +            if (callback === null)
    +            {
    +                delete (this._bodyCallbacks[id]);
    +                delete (this._bodyCallbackContext[id]);
    +            }
    +            else
    +            {
    +                this._bodyCallbacks[id] = callback;
    +                this._bodyCallbackContext[id] = callbackContext;
    +            }
    +        }
    +
    +    },
    +
    +    /**
    +    * Sets a callback to be fired any time this Body impacts with the given Group. The impact test is performed against shape.collisionGroup values.
    +    * The callback will be sent 4 parameters: This body, the body that impacted, the Shape in this body and the shape in the impacting body.
    +    * This callback will only fire if this Body has been assigned a collision group.
    +    * Note that the impact event happens after collision resolution, so it cannot be used to prevent a collision from happening.
    +    * It also happens mid-step. So do not destroy a Body during this callback, instead set safeDestroy to true so it will be killed on the next preUpdate.
    +    *
    +    * @method Phaser.Physics.P2.Body#createGroupCallback
    +    * @param {Phaser.Physics.CollisionGroup} group - The Group to send impact events for.
    +    * @param {function} callback - The callback to fire on impact. Set to null to clear a previously set callback.
    +    * @param {object} callbackContext - The context under which the callback will fire.
    +    */
    +    createGroupCallback: function (group, callback, callbackContext) {
    +
    +        if (callback === null)
    +        {
    +            delete (this._groupCallbacks[group.mask]);
    +            delete (this._groupCallbacksContext[group.mask]);
    +        }
    +        else
    +        {
    +            this._groupCallbacks[group.mask] = callback;
    +            this._groupCallbackContext[group.mask] = callbackContext;
    +        }
    +
    +    },
    +
    +    /**
    +    * Gets the collision bitmask from the groups this body collides with.
    +    *
    +    * @method Phaser.Physics.P2.Body#getCollisionMask
    +    * @return {number} The bitmask.
    +    */
    +    getCollisionMask: function () {
    +
    +        var mask = 0;
    +
    +        if (this._collideWorldBounds)
    +        {
    +            mask = this.game.physics.p2.boundsCollisionGroup.mask;
    +        }
    +
    +        for (var i = 0; i < this.collidesWith.length; i++)
    +        {
    +            mask = mask | this.collidesWith[i].mask;
    +        }
    +
    +        return mask;
    +
    +    },
    +
    +    /**
    +    * Updates the collisionMask.
    +    *
    +    * @method Phaser.Physics.P2.Body#updateCollisionMask
    +    * @param {p2.Shape} [shape] - An optional Shape. If not provided the collision group will be added to all Shapes in this Body.
    +    */
    +    updateCollisionMask: function (shape) {
    +
    +        var mask = this.getCollisionMask();
    +
    +        if (typeof shape === 'undefined')
    +        {
    +            for (var i = this.data.shapes.length - 1; i >= 0; i--)
    +            {
    +                this.data.shapes[i].collisionMask = mask;
    +            }
    +        }
    +        else
    +        {
    +            shape.collisionMask = mask;
    +        }
    +
    +    },
    +
    +    /**
    +    * Sets the given CollisionGroup to be the collision group for all shapes in this Body, unless a shape is specified.
    +    * This also resets the collisionMask.
    +    *
    +    * @method Phaser.Physics.P2.Body#setCollisionGroup
    +    * @param {Phaser.Physics.CollisionGroup} group - The Collision Group that this Bodies shapes will use.
    +    * @param {p2.Shape} [shape] - An optional Shape. If not provided the collision group will be added to all Shapes in this Body.
    +    */
    +    setCollisionGroup: function (group, shape) {
    +
    +        var mask = this.getCollisionMask();
    +
    +        if (typeof shape === 'undefined')
    +        {
    +            for (var i = this.data.shapes.length - 1; i >= 0; i--)
    +            {
    +                this.data.shapes[i].collisionGroup = group.mask;
    +                this.data.shapes[i].collisionMask = mask;
    +            }
    +        }
    +        else
    +        {
    +            shape.collisionGroup = group.mask;
    +            shape.collisionMask = mask;
    +        }
    +
    +    },
    +
    +    /**
    +    * Clears the collision data from the shapes in this Body. Optionally clears Group and/or Mask.
    +    *
    +    * @method Phaser.Physics.P2.Body#clearCollision
    +    * @param {boolean} [clearGroup=true] - Clear the collisionGroup value from the shape/s?
    +    * @param {boolean} [clearMask=true] - Clear the collisionMask value from the shape/s?
    +    * @param {p2.Shape} [shape] - An optional Shape. If not provided the collision data will be cleared from all Shapes in this Body.
    +    */
    +    clearCollision: function (clearGroup, clearMask, shape) {
    +
    +        if (typeof shape === 'undefined')
    +        {
    +            for (var i = this.data.shapes.length - 1; i >= 0; i--)
    +            {
    +                if (clearGroup)
    +                {
    +                    this.data.shapes[i].collisionGroup = null;
    +                }
    +
    +                if (clearMask)
    +                {
    +                    this.data.shapes[i].collisionMask = null;
    +                }
    +            }
    +        }
    +        else
    +        {
    +            if (clearGroup)
    +            {
    +                shape.collisionGroup = null;
    +            }
    +
    +            if (clearMask)
    +            {
    +                shape.collisionMask = null;
    +            }
    +        }
    +
    +        if (clearGroup)
    +        {
    +            this.collidesWith.length = 0;
    +        }
    +
    +    },
    +
    +    /**
    +    * Adds the given CollisionGroup, or array of CollisionGroups, to the list of groups that this body will collide with and updates the collision masks.
    +    *
    +    * @method Phaser.Physics.P2.Body#collides
    +    * @param {Phaser.Physics.CollisionGroup|array} group - The Collision Group or Array of Collision Groups that this Bodies shapes will collide with.
    +    * @param {function} [callback] - Optional callback that will be triggered when this Body impacts with the given Group.
    +    * @param {object} [callbackContext] - The context under which the callback will be called.
    +    * @param {p2.Shape} [shape] - An optional Shape. If not provided the collision mask will be added to all Shapes in this Body.
    +    */
    +    collides: function (group, callback, callbackContext, shape) {
    +
    +        if (Array.isArray(group))
    +        {
    +            for (var i = 0; i < group.length; i++)
    +            {
    +                if (this.collidesWith.indexOf(group[i]) === -1)
    +                {
    +                    this.collidesWith.push(group[i]);
    +
    +                    if (callback)
    +                    {
    +                        this.createGroupCallback(group[i], callback, callbackContext);
    +                    }
    +                }
    +            }
    +        }
    +        else
    +        {
    +            if (this.collidesWith.indexOf(group) === -1)
    +            {
    +                this.collidesWith.push(group);
    +
    +                if (callback)
    +                {
    +                    this.createGroupCallback(group, callback, callbackContext);
    +                }
    +            }
    +        }
    +
    +        var mask = this.getCollisionMask();
    +
    +        if (typeof shape === 'undefined')
    +        {
    +            for (var i = this.data.shapes.length - 1; i >= 0; i--)
    +            {
    +                this.data.shapes[i].collisionMask = mask;
    +            }
    +        }
    +        else
    +        {
    +            shape.collisionMask = mask;
    +        }
    +
    +    },
    +
    +    /**
    +    * Moves the shape offsets so their center of mass becomes the body center of mass.
    +    *
    +    * @method Phaser.Physics.P2.Body#adjustCenterOfMass
    +    */
    +    adjustCenterOfMass: function () {
    +
    +        this.data.adjustCenterOfMass();
    +
    +    },
    +
    +    /**
    +    * Apply damping, see http://code.google.com/p/bullet/issues/detail?id=74 for details.
    +    *
    +    * @method Phaser.Physics.P2.Body#applyDamping
    +    * @param {number} dt - Current time step.
    +    */
    +    applyDamping: function (dt) {
    +
    +        this.data.applyDamping(dt);
    +
    +    },
    +
    +    /**
    +    * Apply force to a world point. This could for example be a point on the RigidBody surface. Applying force this way will add to Body.force and Body.angularForce.
    +    *
    +    * @method Phaser.Physics.P2.Body#applyForce
    +    * @param {number} force - The force to add.
    +    * @param {number} worldX - The world x point to apply the force on.
    +    * @param {number} worldY - The world y point to apply the force on.
    +    */
    +    applyForce: function (force, worldX, worldY) {
    +
    +        this.data.applyForce(force, [this.world.pxm(worldX), this.world.pxm(worldY)]);
    +
    +    },
    +
    +    /**
    +    * Sets the force on the body to zero.
    +    *
    +    * @method Phaser.Physics.P2.Body#setZeroForce
    +    */
    +    setZeroForce: function () {
    +
    +        this.data.setZeroForce();
    +
    +    },
    +
    +    /**
    +    * If this Body is dynamic then this will zero its angular velocity.
    +    *
    +    * @method Phaser.Physics.P2.Body#setZeroRotation
    +    */
    +    setZeroRotation: function () {
    +
    +        this.data.angularVelocity = 0;
    +
    +    },
    +
    +    /**
    +    * If this Body is dynamic then this will zero its velocity on both axis.
    +    *
    +    * @method Phaser.Physics.P2.Body#setZeroVelocity
    +    */
    +    setZeroVelocity: function () {
    +
    +        this.data.velocity[0] = 0;
    +        this.data.velocity[1] = 0;
    +
    +    },
    +
    +    /**
    +    * Sets the Body damping and angularDamping to zero.
    +    *
    +    * @method Phaser.Physics.P2.Body#setZeroDamping
    +    */
    +    setZeroDamping: function () {
    +
    +        this.data.damping = 0;
    +        this.data.angularDamping = 0;
    +
    +    },
    +
    +    /**
    +    * Transform a world point to local body frame.
    +    *
    +    * @method Phaser.Physics.P2.Body#toLocalFrame
    +    * @param {Float32Array|Array} out - The vector to store the result in.
    +    * @param {Float32Array|Array} worldPoint - The input world vector.
    +    */
    +    toLocalFrame: function (out, worldPoint) {
    +
    +        return this.data.toLocalFrame(out, worldPoint);
    +
    +    },
    +
    +    /**
    +    * Transform a local point to world frame.
    +    *
    +    * @method Phaser.Physics.P2.Body#toWorldFrame
    +    * @param {Array} out - The vector to store the result in.
    +    * @param {Array} localPoint - The input local vector.
    +    */
    +    toWorldFrame: function (out, localPoint) {
    +
    +        return this.data.toWorldFrame(out, localPoint);
    +
    +    },
    +
    +    /**
    +    * This will rotate the Body by the given speed to the left (counter-clockwise).
    +    *
    +    * @method Phaser.Physics.P2.Body#rotateLeft
    +    * @param {number} speed - The speed at which it should rotate.
    +    */
    +    rotateLeft: function (speed) {
    +
    +        this.data.angularVelocity = this.world.pxm(-speed);
    +
    +    },
    +
    +    /**
    +    * This will rotate the Body by the given speed to the left (clockwise).
    +    *
    +    * @method Phaser.Physics.P2.Body#rotateRight
    +    * @param {number} speed - The speed at which it should rotate.
    +    */
    +    rotateRight: function (speed) {
    +
    +        this.data.angularVelocity = this.world.pxm(speed);
    +
    +    },
    +
    +    /**
    +    * Moves the Body forwards based on its current angle and the given speed.
    +    * The speed is represented in pixels per second. So a value of 100 would move 100 pixels in 1 second (1000ms).
    +    *
    +    * @method Phaser.Physics.P2.Body#moveForward
    +    * @param {number} speed - The speed at which it should move forwards.
    +    */
    +    moveForward: function (speed) {
    +
    +        var magnitude = this.world.pxmi(-speed);
    +        var angle = this.data.angle + Math.PI / 2;
    +
    +        this.data.velocity[0] = magnitude * Math.cos(angle);
    +        this.data.velocity[1] = magnitude * Math.sin(angle);
    +
    +    },
    +
    +    /**
    +    * Moves the Body backwards based on its current angle and the given speed.
    +    * The speed is represented in pixels per second. So a value of 100 would move 100 pixels in 1 second (1000ms).
    +    *
    +    * @method Phaser.Physics.P2.Body#moveBackward
    +    * @param {number} speed - The speed at which it should move backwards.
    +    */
    +    moveBackward: function (speed) {
    +
    +        var magnitude = this.world.pxmi(-speed);
    +        var angle = this.data.angle + Math.PI / 2;
    +
    +        this.data.velocity[0] = -(magnitude * Math.cos(angle));
    +        this.data.velocity[1] = -(magnitude * Math.sin(angle));
    +
    +    },
    +
    +    /**
    +    * Applies a force to the Body that causes it to 'thrust' forwards, based on its current angle and the given speed.
    +    * The speed is represented in pixels per second. So a value of 100 would move 100 pixels in 1 second (1000ms).
    +    *
    +    * @method Phaser.Physics.P2.Body#thrust
    +    * @param {number} speed - The speed at which it should thrust.
    +    */
    +    thrust: function (speed) {
    +
    +        var magnitude = this.world.pxmi(-speed);
    +        var angle = this.data.angle + Math.PI / 2;
    +
    +        this.data.force[0] += magnitude * Math.cos(angle);
    +        this.data.force[1] += magnitude * Math.sin(angle);
    +
    +    },
    +
    +    /**
    +    * Applies a force to the Body that causes it to 'thrust' backwards (in reverse), based on its current angle and the given speed.
    +    * The speed is represented in pixels per second. So a value of 100 would move 100 pixels in 1 second (1000ms).
    +    *
    +    * @method Phaser.Physics.P2.Body#rever
    +    * @param {number} speed - The speed at which it should reverse.
    +    */
    +    reverse: function (speed) {
    +
    +        var magnitude = this.world.pxmi(-speed);
    +        var angle = this.data.angle + Math.PI / 2;
    +
    +        this.data.force[0] -= magnitude * Math.cos(angle);
    +        this.data.force[1] -= magnitude * Math.sin(angle);
    +
    +    },
    +
    +    /**
    +    * If this Body is dynamic then this will move it to the left by setting its x velocity to the given speed.
    +    * The speed is represented in pixels per second. So a value of 100 would move 100 pixels in 1 second (1000ms).
    +    *
    +    * @method Phaser.Physics.P2.Body#moveLeft
    +    * @param {number} speed - The speed at which it should move to the left, in pixels per second.
    +    */
    +    moveLeft: function (speed) {
    +
    +        this.data.velocity[0] = this.world.pxmi(-speed);
    +
    +    },
    +
    +    /**
    +    * If this Body is dynamic then this will move it to the right by setting its x velocity to the given speed.
    +    * The speed is represented in pixels per second. So a value of 100 would move 100 pixels in 1 second (1000ms).
    +    *
    +    * @method Phaser.Physics.P2.Body#moveRight
    +    * @param {number} speed - The speed at which it should move to the right, in pixels per second.
    +    */
    +    moveRight: function (speed) {
    +
    +        this.data.velocity[0] = this.world.pxmi(speed);
    +
    +    },
    +
    +    /**
    +    * If this Body is dynamic then this will move it up by setting its y velocity to the given speed.
    +    * The speed is represented in pixels per second. So a value of 100 would move 100 pixels in 1 second (1000ms).
    +    *
    +    * @method Phaser.Physics.P2.Body#moveUp
    +    * @param {number} speed - The speed at which it should move up, in pixels per second.
    +    */
    +    moveUp: function (speed) {
    +
    +        this.data.velocity[1] = this.world.pxmi(-speed);
    +
    +    },
    +
    +    /**
    +    * If this Body is dynamic then this will move it down by setting its y velocity to the given speed.
    +    * The speed is represented in pixels per second. So a value of 100 would move 100 pixels in 1 second (1000ms).
    +    *
    +    * @method Phaser.Physics.P2.Body#moveDown
    +    * @param {number} speed - The speed at which it should move down, in pixels per second.
    +    */
    +    moveDown: function (speed) {
    +
    +        this.data.velocity[1] = this.world.pxmi(speed);
    +
    +    },
    +
    +    /**
    +    * Internal method. This is called directly before the sprites are sent to the renderer and after the update function has finished.
    +    *
    +    * @method Phaser.Physics.P2.Body#preUpdate
    +    * @protected
    +    */
    +    preUpdate: function () {
    +
    +        if (this.removeNextStep)
    +        {
    +            this.removeFromWorld();
    +            this.removeNextStep = false;
    +        }
    +
    +    },
    +
    +    /**
    +    * Internal method. This is called directly before the sprites are sent to the renderer and after the update function has finished.
    +    *
    +    * @method Phaser.Physics.P2.Body#postUpdate
    +    * @protected
    +    */
    +    postUpdate: function () {
    +
    +        this.sprite.x = this.world.mpxi(this.data.position[0]);
    +        this.sprite.y = this.world.mpxi(this.data.position[1]);
    +
    +        if (!this.fixedRotation)
    +        {
    +            this.sprite.rotation = this.data.angle;
    +        }
    +
    +    },
    +
    +    /**
    +    * Resets the Body force, velocity (linear and angular) and rotation. Optionally resets damping and mass.
    +    *
    +    * @method Phaser.Physics.P2.Body#reset
    +    * @param {number} x - The new x position of the Body.
    +    * @param {number} y - The new x position of the Body.
    +    * @param {boolean} [resetDamping=false] - Resets the linear and angular damping.
    +    * @param {boolean} [resetMass=false] - Sets the Body mass back to 1.
    +    */
    +    reset: function (x, y, resetDamping, resetMass) {
    +
    +        if (typeof resetDamping === 'undefined') { resetDamping = false; }
    +        if (typeof resetMass === 'undefined') { resetMass = false; }
    +
    +        this.setZeroForce();
    +        this.setZeroVelocity();
    +        this.setZeroRotation();
    +
    +        if (resetDamping)
    +        {
    +            this.setZeroDamping();
    +        }
    +
    +        if (resetMass)
    +        {
    +            this.mass = 1;
    +        }
    +
    +        this.x = x;
    +        this.y = y;
    +
    +    },
    +
    +    /**
    +    * Adds this physics body to the world.
    +    *
    +    * @method Phaser.Physics.P2.Body#addToWorld
    +    */
    +    addToWorld: function () {
    +
    +        if (this.data.world !== this.game.physics.p2.world)
    +        {
    +            this.game.physics.p2.addBody(this);
    +        }
    +
    +    },
    +
    +    /**
    +    * Removes this physics body from the world.
    +    *
    +    * @method Phaser.Physics.P2.Body#removeFromWorld
    +    */
    +    removeFromWorld: function () {
    +
    +        if (this.data.world === this.game.physics.p2.world)
    +        {
    +            this.game.physics.p2.removeBodyNextStep(this);
    +        }
    +
    +    },
    +
    +    /**
    +    * Destroys this Body and all references it holds to other objects.
    +    *
    +    * @method Phaser.Physics.P2.Body#destroy
    +    */
    +    destroy: function () {
    +
    +        this.removeFromWorld();
    +
    +        this.clearShapes();
    +
    +        this._bodyCallbacks = {};
    +        this._bodyCallbackContext = {};
    +        this._groupCallbacks = {};
    +        this._groupCallbackContext = {};
    +
    +        if (this.debugBody)
    +        {
    +            this.debugBody.destroy();
    +        }
    +
    +        this.debugBody = null
    +
    +        this.sprite = null;
    +
    +    },
    +
    +    /**
    +    * Removes all Shapes from this Body.
    +    *
    +    * @method Phaser.Physics.P2.Body#clearShapes
    +    */
    +    clearShapes: function () {
    +
    +        var i = this.data.shapes.length;
    +
    +        while (i--)
    +        {
    +            this.data.removeShape(this.data.shapes[i]);
    +        }
    +
    +        this.shapeChanged();
    +
    +    },
    +
    +    /**
    +    * Add a shape to the body. You can pass a local transform when adding a shape, so that the shape gets an offset and an angle relative to the body center of mass.
    +    * Will automatically update the mass properties and bounding radius.
    +    *
    +    * @method Phaser.Physics.P2.Body#addShape
    +    * @param {*} shape - The shape to add to the body.
    +    * @param {number} [offsetX=0] - Local horizontal offset of the shape relative to the body center of mass.
    +    * @param {number} [offsetY=0] - Local vertical offset of the shape relative to the body center of mass.
    +    * @param {number} [rotation=0] - Local rotation of the shape relative to the body center of mass, specified in radians.
    +    * @return {p2.Circle|p2.Rectangle|p2.Plane|p2.Line|p2.Particle} The shape that was added to the body.
    +    */
    +    addShape: function (shape, offsetX, offsetY, rotation) {
    +
    +        if (typeof offsetX === 'undefined') { offsetX = 0; }
    +        if (typeof offsetY === 'undefined') { offsetY = 0; }
    +        if (typeof rotation === 'undefined') { rotation = 0; }
    +
    +        this.data.addShape(shape, [this.world.pxmi(offsetX), this.world.pxmi(offsetY)], rotation);
    +        this.shapeChanged();
    +
    +        return shape;
    +
    +    },
    +
    +    /**
    +    * Adds a Circle shape to this Body. You can control the offset from the center of the body and the rotation.
    +    *
    +    * @method Phaser.Physics.P2.Body#addCircle
    +    * @param {number} radius - The radius of this circle (in pixels)
    +    * @param {number} [offsetX=0] - Local horizontal offset of the shape relative to the body center of mass.
    +    * @param {number} [offsetY=0] - Local vertical offset of the shape relative to the body center of mass.
    +    * @param {number} [rotation=0] - Local rotation of the shape relative to the body center of mass, specified in radians.
    +    * @return {p2.Circle} The Circle shape that was added to the Body.
    +    */
    +    addCircle: function (radius, offsetX, offsetY, rotation) {
    +
    +        var shape = new p2.Circle(this.world.pxm(radius));
    +
    +        return this.addShape(shape, offsetX, offsetY, rotation);
    +
    +    },
    +
    +    /**
    +    * Adds a Rectangle shape to this Body. You can control the offset from the center of the body and the rotation.
    +    *
    +    * @method Phaser.Physics.P2.Body#addRectangle
    +    * @param {number} width - The width of the rectangle in pixels.
    +    * @param {number} height - The height of the rectangle in pixels.
    +    * @param {number} [offsetX=0] - Local horizontal offset of the shape relative to the body center of mass.
    +    * @param {number} [offsetY=0] - Local vertical offset of the shape relative to the body center of mass.
    +    * @param {number} [rotation=0] - Local rotation of the shape relative to the body center of mass, specified in radians.
    +    * @return {p2.Rectangle} The Rectangle shape that was added to the Body.
    +    */
    +    addRectangle: function (width, height, offsetX, offsetY, rotation) {
    +
    +        var shape = new p2.Rectangle(this.world.pxm(width), this.world.pxm(height));
    +
    +        return this.addShape(shape, offsetX, offsetY, rotation);
    +
    +    },
    +
    +    /**
    +    * Adds a Plane shape to this Body. The plane is facing in the Y direction. You can control the offset from the center of the body and the rotation.
    +    *
    +    * @method Phaser.Physics.P2.Body#addPlane
    +    * @param {number} [offsetX=0] - Local horizontal offset of the shape relative to the body center of mass.
    +    * @param {number} [offsetY=0] - Local vertical offset of the shape relative to the body center of mass.
    +    * @param {number} [rotation=0] - Local rotation of the shape relative to the body center of mass, specified in radians.
    +    * @return {p2.Plane} The Plane shape that was added to the Body.
    +    */
    +    addPlane: function (offsetX, offsetY, rotation) {
    +
    +        var shape = new p2.Plane();
    +
    +        return this.addShape(shape, offsetX, offsetY, rotation);
    +
    +    },
    +
    +    /**
    +    * Adds a Particle shape to this Body. You can control the offset from the center of the body and the rotation.
    +    *
    +    * @method Phaser.Physics.P2.Body#addParticle
    +    * @param {number} [offsetX=0] - Local horizontal offset of the shape relative to the body center of mass.
    +    * @param {number} [offsetY=0] - Local vertical offset of the shape relative to the body center of mass.
    +    * @param {number} [rotation=0] - Local rotation of the shape relative to the body center of mass, specified in radians.
    +    * @return {p2.Particle} The Particle shape that was added to the Body.
    +    */
    +    addParticle: function (offsetX, offsetY, rotation) {
    +
    +        var shape = new p2.Particle();
    +
    +        return this.addShape(shape, offsetX, offsetY, rotation);
    +
    +    },
    +
    +    /**
    +    * Adds a Line shape to this Body.
    +    * The line shape is along the x direction, and stretches from [-length/2, 0] to [length/2,0].
    +    * You can control the offset from the center of the body and the rotation.
    +    *
    +    * @method Phaser.Physics.P2.Body#addLine
    +    * @param {number} length - The length of this line (in pixels)
    +    * @param {number} [offsetX=0] - Local horizontal offset of the shape relative to the body center of mass.
    +    * @param {number} [offsetY=0] - Local vertical offset of the shape relative to the body center of mass.
    +    * @param {number} [rotation=0] - Local rotation of the shape relative to the body center of mass, specified in radians.
    +    * @return {p2.Line} The Line shape that was added to the Body.
    +    */
    +    addLine: function (length, offsetX, offsetY, rotation) {
    +
    +        var shape = new p2.Line(this.world.pxm(length));
    +
    +        return this.addShape(shape, offsetX, offsetY, rotation);
    +
    +    },
    +
    +    /**
    +    * Adds a Capsule shape to this Body.
    +    * You can control the offset from the center of the body and the rotation.
    +    *
    +    * @method Phaser.Physics.P2.Body#addCapsule
    +    * @param {number} length - The distance between the end points in pixels.
    +    * @param {number} radius - Radius of the capsule in radians.
    +    * @param {number} [offsetX=0] - Local horizontal offset of the shape relative to the body center of mass.
    +    * @param {number} [offsetY=0] - Local vertical offset of the shape relative to the body center of mass.
    +    * @param {number} [rotation=0] - Local rotation of the shape relative to the body center of mass, specified in radians.
    +    * @return {p2.Capsule} The Capsule shape that was added to the Body.
    +    */
    +    addCapsule: function (length, radius, offsetX, offsetY, rotation) {
    +
    +        var shape = new p2.Capsule(this.world.pxm(length), radius);
    +
    +        return this.addShape(shape, offsetX, offsetY, rotation);
    +
    +    },
    +
    +    /**
    +    * Reads a polygon shape path, and assembles convex shapes from that and puts them at proper offset points. The shape must be simple and without holes.
    +    * This function expects the x.y values to be given in pixels. If you want to provide them at p2 world scales then call Body.data.fromPolygon directly.
    +    *
    +    * @method Phaser.Physics.P2.Body#addPolygon
    +    * @param {object} options - An object containing the build options: 
    +    * @param {boolean} [options.optimalDecomp=false] - Set to true if you need optimal decomposition. Warning: very slow for polygons with more than 10 vertices.
    +    * @param {boolean} [options.skipSimpleCheck=false] - Set to true if you already know that the path is not intersecting itself.
    +    * @param {boolean|number} [options.removeCollinearPoints=false] - Set to a number (angle threshold value) to remove collinear points, or false to keep all points.
    +    * @param {(number[]|...number)} points - An array of 2d vectors that form the convex or concave polygon. 
    +    *                                       Either [[0,0], [0,1],...] or a flat array of numbers that will be interpreted as [x,y, x,y, ...], 
    +    *                                       or the arguments passed can be flat x,y values e.g. `setPolygon(options, x,y, x,y, x,y, ...)` where `x` and `y` are numbers.
    +    * @return {boolean} True on success, else false.
    +    */
    +    addPolygon: function (options, points) {
    +
    +        options = options || {};
    +
    +        points = Array.prototype.slice.call(arguments, 1);
    +
    +        var path = [];
    +
    +        //  Did they pass in a single array of points?
    +        if (points.length === 1 && Array.isArray(points[0]))
    +        {
    +            path = points[0].slice(0);
    +        }
    +        else if (Array.isArray(points[0]))
    +        {
    +            path = points[0].slice(0);
    +        }
    +        else if (typeof points[0] === 'number')
    +        {
    +            //  We've a list of numbers
    +            for (var i = 0, len = points.length; i < len; i += 2)
    +            {
    +                path.push([points[i], points[i + 1]]);
    +            }
    +        }
    +
    +        //  top and tail
    +        var idx = path.length - 1;
    +
    +        if ( path[idx][0] === path[0][0] && path[idx][1] === path[0][1] )
    +        {
    +            path.pop();
    +        }
    +
    +        //  Now process them into p2 values
    +        for (var p = 0; p < path.length; p++)
    +        {
    +            path[p][0] = this.world.pxmi(path[p][0]);
    +            path[p][1] = this.world.pxmi(path[p][1]);
    +        }
    +
    +        var result = this.data.fromPolygon(path, options);
    +
    +        this.shapeChanged();
    +
    +        return result;
    +
    +    },
    +
    +    /**
    +    * Remove a shape from the body. Will automatically update the mass properties and bounding radius.
    +    *
    +    * @method Phaser.Physics.P2.Body#removeShape
    +    * @param {p2.Circle|p2.Rectangle|p2.Plane|p2.Line|p2.Particle} shape - The shape to remove from the body.
    +    * @return {boolean} True if the shape was found and removed, else false.
    +    */
    +    removeShape: function (shape) {
    +
    +        return this.data.removeShape(shape);
    +
    +    },
    +
    +    /**
    +    * Clears any previously set shapes. Then creates a new Circle shape and adds it to this Body.
    +    *
    +    * @method Phaser.Physics.P2.Body#setCircle
    +    * @param {number} radius - The radius of this circle (in pixels)
    +    * @param {number} [offsetX=0] - Local horizontal offset of the shape relative to the body center of mass.
    +    * @param {number} [offsetY=0] - Local vertical offset of the shape relative to the body center of mass.
    +    * @param {number} [rotation=0] - Local rotation of the shape relative to the body center of mass, specified in radians.
    +    */
    +    setCircle: function (radius, offsetX, offsetY, rotation) {
    +
    +        this.clearShapes();
    +
    +        this.addCircle(radius, offsetX, offsetY, rotation);
    +
    +    },
    +
    +    /**
    +    * Clears any previously set shapes. The creates a new Rectangle shape at the given size and offset, and adds it to this Body.
    +    * If you wish to create a Rectangle to match the size of a Sprite or Image see Body.setRectangleFromSprite.
    +    *
    +    * @method Phaser.Physics.P2.Body#setRectangle
    +    * @param {number} [width=16] - The width of the rectangle in pixels.
    +    * @param {number} [height=16] - The height of the rectangle in pixels.
    +    * @param {number} [offsetX=0] - Local horizontal offset of the shape relative to the body center of mass.
    +    * @param {number} [offsetY=0] - Local vertical offset of the shape relative to the body center of mass.
    +    * @param {number} [rotation=0] - Local rotation of the shape relative to the body center of mass, specified in radians.
    +    * @return {p2.Rectangle} The Rectangle shape that was added to the Body.
    +    */
    +    setRectangle: function (width, height, offsetX, offsetY, rotation) {
    +
    +        if (typeof width === 'undefined') { width = 16; }
    +        if (typeof height === 'undefined') { height = 16; }
    +
    +        this.clearShapes();
    +
    +        return this.addRectangle(width, height, offsetX, offsetY, rotation);
    +
    +    },
    +
    +    /**
    +    * Clears any previously set shapes.
    +    * Then creates a Rectangle shape sized to match the dimensions and orientation of the Sprite given.
    +    * If no Sprite is given it defaults to using the parent of this Body.
    +    *
    +    * @method Phaser.Physics.P2.Body#setRectangleFromSprite
    +    * @param {Phaser.Sprite|Phaser.Image} [sprite] - The Sprite on which the Rectangle will get its dimensions.
    +    * @return {p2.Rectangle} The Rectangle shape that was added to the Body.
    +    */
    +    setRectangleFromSprite: function (sprite) {
    +
    +        if (typeof sprite === 'undefined') { sprite = this.sprite; }
    +
    +        this.clearShapes();
    +
    +        return this.addRectangle(sprite.width, sprite.height, 0, 0, sprite.rotation);
    +
    +    },
    +
    +    /**
    +    * Adds the given Material to all Shapes that belong to this Body.
    +    * If you only wish to apply it to a specific Shape in this Body then provide that as the 2nd parameter.
    +    *
    +    * @method Phaser.Physics.P2.Body#setMaterial
    +    * @param {Phaser.Physics.Material} material - The Material that will be applied.
    +    * @param {p2.Shape} [shape] - An optional Shape. If not provided the Material will be added to all Shapes in this Body.
    +    */
    +    setMaterial: function (material, shape) {
    +
    +        if (typeof shape === 'undefined')
    +        {
    +            for (var i = this.data.shapes.length - 1; i >= 0; i--)
    +            {
    +                this.data.shapes[i].material = material;
    +            }
    +        }
    +        else
    +        {
    +            shape.material = material;
    +        }
    +
    +    },
    +      
    +    /**
    +    * Updates the debug draw if any body shapes change.
    +    *
    +    * @method Phaser.Physics.P2.Body#shapeChanged
    +    */
    +    shapeChanged: function() {
    +
    +        if (this.debugBody)
    +        {
    +            this.debugBody.draw();
    +        }
    +
    +    },
    +
    +    /**
    +    * Reads the shape data from a physics data file stored in the Game.Cache and adds it as a polygon to this Body.
    +    *
    +    * @method Phaser.Physics.P2.Body#loadPolygon
    +    * @param {string} key - The key of the Physics Data file as stored in Game.Cache.
    +    * @param {string} object - The key of the object within the Physics data file that you wish to load the shape data from.
    +    * @param {object} options - An object containing the build options. Note that this isn't used if the data file contains multiple shapes.
    +    * @param {boolean} [options.optimalDecomp=false] - Set to true if you need optimal decomposition. Warning: very slow for polygons with more than 10 vertices.
    +    * @param {boolean} [options.skipSimpleCheck=false] - Set to true if you already know that the path is not intersecting itself.
    +    * @param {boolean|number} [options.removeCollinearPoints=false] - Set to a number (angle threshold value) to remove collinear points, or false to keep all points.
    +    * @return {boolean} True on success, else false.
    +    */
    +    loadPolygon: function (key, object, options) {
    +
    +        var data = this.game.cache.getPhysicsData(key, object);
    +
    +        if (data.length === 1)
    +        {
    +            var temp = [];
    +
    +            data = data.pop()
    +            //  We've a list of numbers
    +            for (var i = 0, len = data.shape.length; i < len; i += 2)
    +            {
    +                temp.push([data.shape[i], data.shape[i + 1]]);
    +            }
    +
    +            return this.addPolygon(options, temp);
    +        }
    +        else
    +        {
    +            //  We've multiple Convex shapes, they should be CCW automatically
    +            var cm = p2.vec2.create();
    +
    +            for (var i = 0; i < data.length; i++)
    +            {
    +                var vertices = [];
    +
    +                for (var s = 0; s < data[i].shape.length; s += 2)
    +                {
    +                    vertices.push([ this.world.pxmi(data[i].shape[s]), this.world.pxmi(data[i].shape[s + 1]) ]);
    +                }
    +
    +                var c = new p2.Convex(vertices);
    +
    +                // Move all vertices so its center of mass is in the local center of the convex
    +                for (var j = 0; j !== c.vertices.length; j++)
    +                {
    +                    var v = c.vertices[j];
    +                    p2.vec2.sub(v, v, c.centerOfMass);
    +                }
    +
    +                p2.vec2.scale(cm, c.centerOfMass, 1);
    +
    +                cm[0] -= this.world.pxmi(this.sprite.width / 2);
    +                cm[1] -= this.world.pxmi(this.sprite.height / 2);
    +
    +                c.updateTriangles();
    +                c.updateCenterOfMass();
    +                c.updateBoundingRadius();
    +
    +                this.data.addShape(c, cm);
    +            }
    +
    +            this.data.aabbNeedsUpdate = true;
    +            this.shapeChanged();
    +
    +            return true;
    +
    +        }
    +
    +        return false;
    +
    +    },
    +
    +    /**
    +    * Reads the physics data from a physics data file stored in the Game.Cache.
    +    * It will add the shape data to this Body, as well as set the density (mass), friction and bounce (restitution) values.
    +    *
    +    * @method Phaser.Physics.P2.Body#loadPolygon
    +    * @param {string} key - The key of the Physics Data file as stored in Game.Cache.
    +    * @param {string} object - The key of the object within the Physics data file that you wish to load the shape data from.
    +    * @param {object} options - An object containing the build options: 
    +    * @param {boolean} [options.optimalDecomp=false] - Set to true if you need optimal decomposition. Warning: very slow for polygons with more than 10 vertices.
    +    * @param {boolean} [options.skipSimpleCheck=false] - Set to true if you already know that the path is not intersecting itself.
    +    * @param {boolean|number} [options.removeCollinearPoints=false] - Set to a number (angle threshold value) to remove collinear points, or false to keep all points.
    +    * @return {boolean} True on success, else false.
    +    */
    +    loadData: function (key, object, options) {
    +
    +        var data = this.game.cache.getPhysicsData(key, object);
    +
    +        if (data && data.shape)
    +        {
    +            this.mass = data.density;
    +            this.loadPolygon(key, object, options);
    +            //  TODO set friction + bounce here
    +        }
    +
    +    }
    +
    +};
    +
    +Phaser.Physics.P2.Body.prototype.constructor = Phaser.Physics.P2.Body;
    +
    +/**
    +* @name Phaser.Physics.P2.Body#static
    +* @property {boolean} static - Returns true if the Body is static. Setting Body.static to 'false' will make it dynamic.
    +*/
    +Object.defineProperty(Phaser.Physics.P2.Body.prototype, "static", {
    +    
    +    get: function () {
    +
    +        return (this.data.motionState === Phaser.STATIC);
    +
    +    },
    +
    +    set: function (value) {
    +
    +        if (value && this.data.motionState !== Phaser.STATIC)
    +        {
    +            this.data.motionState = Phaser.STATIC;
    +            this.mass = 0;
    +        }
    +        else if (!value && this.data.motionState === Phaser.STATIC)
    +        {
    +            this.data.motionState = Phaser.DYNAMIC;
    +
    +            if (this.mass === 0)
    +            {
    +                this.mass = 1;
    +            }
    +        }
    +
    +    }
    +
    +});
    +
    +/**
    +* @name Phaser.Physics.P2.Body#dynamic
    +* @property {boolean} dynamic - Returns true if the Body is dynamic. Setting Body.dynamic to 'false' will make it static.
    +*/
    +Object.defineProperty(Phaser.Physics.P2.Body.prototype, "dynamic", {
    +    
    +    get: function () {
    +
    +        return (this.data.motionState === Phaser.DYNAMIC);
    +
    +    },
    +
    +    set: function (value) {
    +
    +        if (value && this.data.motionState !== Phaser.DYNAMIC)
    +        {
    +            this.data.motionState = Phaser.DYNAMIC;
    +
    +            if (this.mass === 0)
    +            {
    +                this.mass = 1;
    +            }
    +        }
    +        else if (!value && this.data.motionState === Phaser.DYNAMIC)
    +        {
    +            this.data.motionState = Phaser.STATIC;
    +            this.mass = 0;
    +        }
    +
    +    }
    +
    +});
    +
    +/**
    +* @name Phaser.Physics.P2.Body#kinematic
    +* @property {boolean} kinematic - Returns true if the Body is kinematic. Setting Body.kinematic to 'false' will make it static.
    +*/
    +Object.defineProperty(Phaser.Physics.P2.Body.prototype, "kinematic", {
    +    
    +    get: function () {
    +
    +        return (this.data.motionState === Phaser.KINEMATIC);
    +
    +    },
    +
    +    set: function (value) {
    +
    +        if (value && this.data.motionState !== Phaser.KINEMATIC)
    +        {
    +            this.data.motionState = Phaser.KINEMATIC;
    +            this.mass = 4;
    +        }
    +        else if (!value && this.data.motionState === Phaser.KINEMATIC)
    +        {
    +            this.data.motionState = Phaser.STATIC;
    +            this.mass = 0;
    +        }
    +
    +    }
    +
    +});
    +
    +/**
    +* @name Phaser.Physics.P2.Body#allowSleep
    +* @property {boolean} allowSleep - 
    +*/
    +Object.defineProperty(Phaser.Physics.P2.Body.prototype, "allowSleep", {
    +    
    +    get: function () {
    +
    +        return this.data.allowSleep;
    +
    +    },
    +
    +    set: function (value) {
    +
    +        if (value !== this.data.allowSleep)
    +        {
    +            this.data.allowSleep = value;
    +        }
    +
    +    }
    +
    +});
    +
    +/**
    +* The angle of the Body in degrees from its original orientation. Values from 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation.
    +* Values outside this range are added to or subtracted from 360 to obtain a value within the range. For example, the statement Body.angle = 450 is the same as Body.angle = 90.
    +* If you wish to work in radians instead of degrees use the property Body.rotation instead. Working in radians is faster as it doesn't have to convert values.
    +* 
    +* @name Phaser.Physics.P2.Body#angle
    +* @property {number} angle - The angle of this Body in degrees.
    +*/
    +Object.defineProperty(Phaser.Physics.P2.Body.prototype, "angle", {
    +
    +    get: function() {
    +
    +        return Phaser.Math.wrapAngle(Phaser.Math.radToDeg(this.data.angle));
    +
    +    },
    +
    +    set: function(value) {
    +
    +        this.data.angle = Phaser.Math.degToRad(Phaser.Math.wrapAngle(value));
    +
    +    }
    +
    +});
    +
    +/**
    +* Damping is specified as a value between 0 and 1, which is the proportion of velocity lost per second.
    +* @name Phaser.Physics.P2.Body#angularDamping
    +* @property {number} angularDamping - The angular damping acting acting on the body.
    +*/
    +Object.defineProperty(Phaser.Physics.P2.Body.prototype, "angularDamping", {
    +    
    +    get: function () {
    +
    +        return this.data.angularDamping;
    +
    +    },
    +
    +    set: function (value) {
    +
    +        this.data.angularDamping = value;
    +
    +    }
    +
    +});
    +
    +/**
    +* @name Phaser.Physics.P2.Body#angularForce
    +* @property {number} angularForce - The angular force acting on the body.
    +*/
    +Object.defineProperty(Phaser.Physics.P2.Body.prototype, "angularForce", {
    +    
    +    get: function () {
    +
    +        return this.data.angularForce;
    +
    +    },
    +
    +    set: function (value) {
    +
    +        this.data.angularForce = value;
    +
    +    }
    +
    +});
    +
    +/**
    +* @name Phaser.Physics.P2.Body#angularVelocity
    +* @property {number} angularVelocity - The angular velocity of the body.
    +*/
    +Object.defineProperty(Phaser.Physics.P2.Body.prototype, "angularVelocity", {
    +    
    +    get: function () {
    +
    +        return this.data.angularVelocity;
    +
    +    },
    +
    +    set: function (value) {
    +
    +        this.data.angularVelocity = value;
    +
    +    }
    +
    +});
    +
    +/**
    +* Damping is specified as a value between 0 and 1, which is the proportion of velocity lost per second.
    +* @name Phaser.Physics.P2.Body#damping
    +* @property {number} damping - The linear damping acting on the body in the velocity direction.
    +*/
    +Object.defineProperty(Phaser.Physics.P2.Body.prototype, "damping", {
    +    
    +    get: function () {
    +
    +        return this.data.damping;
    +
    +    },
    +
    +    set: function (value) {
    +
    +        this.data.damping = value;
    +
    +    }
    +
    +});
    +
    +/**
    +* @name Phaser.Physics.P2.Body#fixedRotation
    +* @property {boolean} fixedRotation - 
    +*/
    +Object.defineProperty(Phaser.Physics.P2.Body.prototype, "fixedRotation", {
    +    
    +    get: function () {
    +
    +        return this.data.fixedRotation;
    +
    +    },
    +
    +    set: function (value) {
    +
    +        if (value !== this.data.fixedRotation)
    +        {
    +            this.data.fixedRotation = value;
    +        }
    +
    +    }
    +
    +});
    +
    +/**
    +* @name Phaser.Physics.P2.Body#inertia
    +* @property {number} inertia - The inertia of the body around the Z axis..
    +*/
    +Object.defineProperty(Phaser.Physics.P2.Body.prototype, "inertia", {
    +    
    +    get: function () {
    +
    +        return this.data.inertia;
    +
    +    },
    +
    +    set: function (value) {
    +
    +        this.data.inertia = value;
    +
    +    }
    +
    +});
    +
    +/**
    +* @name Phaser.Physics.P2.Body#mass
    +* @property {number} mass - 
    +*/
    +Object.defineProperty(Phaser.Physics.P2.Body.prototype, "mass", {
    +    
    +    get: function () {
    +
    +        return this.data.mass;
    +
    +    },
    +
    +    set: function (value) {
    +
    +        if (value !== this.data.mass)
    +        {
    +            this.data.mass = value;
    +            this.data.updateMassProperties();
    +        }
    +
    +    }
    +
    +});
    +
    +/**
    +* @name Phaser.Physics.P2.Body#motionState
    +* @property {number} motionState - The type of motion this body has. Should be one of: Body.STATIC (the body does not move), Body.DYNAMIC (body can move and respond to collisions) and Body.KINEMATIC (only moves according to its .velocity).
    +*/
    +Object.defineProperty(Phaser.Physics.P2.Body.prototype, "motionState", {
    +    
    +    get: function () {
    +
    +        return this.data.motionState;
    +
    +    },
    +
    +    set: function (value) {
    +
    +        if (value !== this.data.motionState)
    +        {
    +            this.data.motionState = value;
    +        }
    +
    +    }
    +
    +});
    +
    +/**
    +* The angle of the Body in radians.
    +* If you wish to work in degrees instead of radians use the Body.angle property instead. Working in radians is faster as it doesn't have to convert values.
    +* 
    +* @name Phaser.Physics.P2.Body#rotation
    +* @property {number} rotation - The angle of this Body in radians.
    +*/
    +Object.defineProperty(Phaser.Physics.P2.Body.prototype, "rotation", {
    +
    +    get: function() {
    +
    +        return this.data.angle;
    +
    +    },
    +
    +    set: function(value) {
    +
    +        this.data.angle = value;
    +
    +    }
    +
    +});
    +
    +/**
    +* @name Phaser.Physics.P2.Body#sleepSpeedLimit
    +* @property {number} sleepSpeedLimit - .
    +*/
    +Object.defineProperty(Phaser.Physics.P2.Body.prototype, "sleepSpeedLimit", {
    +    
    +    get: function () {
    +
    +        return this.data.sleepSpeedLimit;
    +
    +    },
    +
    +    set: function (value) {
    +
    +        this.data.sleepSpeedLimit = value;
    +
    +    }
    +
    +});
    +
    +/**
    +* @name Phaser.Physics.P2.Body#x
    +* @property {number} x - The x coordinate of this Body.
    +*/
    +Object.defineProperty(Phaser.Physics.P2.Body.prototype, "x", {
    +    
    +    get: function () {
    +
    +        return this.world.mpxi(this.data.position[0]);
    +
    +    },
    +
    +    set: function (value) {
    +
    +        this.data.position[0] = this.world.pxmi(value);
    +
    +    }
    +
    +});
    +
    +/**
    +* @name Phaser.Physics.P2.Body#y
    +* @property {number} y - The y coordinate of this Body.
    +*/
    +Object.defineProperty(Phaser.Physics.P2.Body.prototype, "y", {
    +    
    +    get: function () {
    +
    +        return this.world.mpxi(this.data.position[1]);
    +
    +    },
    +
    +    set: function (value) {
    +
    +        this.data.position[1] = this.world.pxmi(value);
    +
    +    }
    +
    +});
    +
    +/**
    +* @name Phaser.Physics.P2.Body#id
    +* @property {number} id - The Body ID. Each Body that has been added to the World has a unique ID.
    +* @readonly
    +*/
    +Object.defineProperty(Phaser.Physics.P2.Body.prototype, "id", {
    +    
    +    get: function () {
    +
    +        return this.data.id;
    +
    +    }
    +
    +});
    +
    +/**
    +* @name Phaser.Physics.P2.Body#debug
    +* @property {boolean} debug - Enable or disable debug drawing of this body
    +*/
    +Object.defineProperty(Phaser.Physics.P2.Body.prototype, "debug", {
    +    
    +    get: function () {
    +
    +        return (!this.debugBody);
    +
    +    },
    +
    +    set: function (value) {
    +
    +        if (value && !this.debugBody)
    +        {
    +            //  This will be added to the global space
    +            this.debugBody = new Phaser.Physics.P2.BodyDebug(this.game, this.data)
    +        }
    +        else if (!value && this.debugBody)
    +        {
    +            this.debugBody.destroy();
    +            this.debugBody = null;
    +        }
    +
    +    }
    +
    +});
    +
    +/**
    +* A Body can be set to collide against the World bounds automatically if this is set to true. Otherwise it will leave the World.
    +* Note that this only applies if your World has bounds! The response to the collision should be managed via CollisionMaterials.
    +* @name Phaser.Physics.P2.Body#collideWorldBounds
    +* @property {boolean} collideWorldBounds - Should the Body collide with the World bounds?
    +*/
    +Object.defineProperty(Phaser.Physics.P2.Body.prototype, "collideWorldBounds", {
    +    
    +    get: function () {
    +
    +        return this._collideWorldBounds;
    +
    +    },
    +
    +    set: function (value) {
    +
    +        if (value && !this._collideWorldBounds)
    +        {
    +            this._collideWorldBounds = true;
    +            this.updateCollisionMask();
    +        }
    +        else if (!value && this._collideWorldBounds)
    +        {
    +            this._collideWorldBounds = false;
    +            this.updateCollisionMask();
    +        }
    +
    +    }
    +
    +});
    +
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2014 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Mar 14 2014 06:34:18 GMT-0000 (GMT) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/BodyDebug.js.html b/docs/BodyDebug.js.html new file mode 100644 index 0000000000..cc634b9237 --- /dev/null +++ b/docs/BodyDebug.js.html @@ -0,0 +1,1000 @@ + + + + + + Phaser Source: physics/p2/BodyDebug.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: physics/p2/BodyDebug.js

    + +
    +
    +
    /**
    +* @author       George https://github.com/georgiee
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2014 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* Draws a P2 Body to a Graphics instance for visual debugging.
    +* Needless to say, for every body you enable debug drawing on, you are adding processor and graphical overhead.
    +* So use sparingly and rarely (if ever) in production code.
    +*
    +* @class Phaser.Physics.P2.BodyDebug
    +* @classdesc Physics Body Debug Constructor
    +* @constructor
    +* @extends Phaser.Group
    +* @param {Phaser.Game} game - Game reference to the currently running game.
    +* @param {Phaser.Physics.P2.Body} body - The P2 Body to display debug data for.
    +* @param {object} settings - Settings object.
    +*/
    +Phaser.Physics.P2.BodyDebug = function(game, body, settings) {
    +
    +    Phaser.Group.call(this, game);
    +
    +    /**
    +    * @property {object} defaultSettings - Default debug settings.
    +    * @private
    +    */
    +    var defaultSettings = {
    +        pixelsPerLengthUnit: 20,
    +        debugPolygons: false,
    +        lineWidth: 1,
    +        alpha: 0.5
    +    }
    +
    +    this.settings = Phaser.Utils.extend(defaultSettings, settings);
    +
    +    /**
    +    * @property {number} ppu - Pixels per Length Unit.
    +    */
    +    this.ppu = this.settings.pixelsPerLengthUnit;
    +    this.ppu = -1 * this.ppu;
    +
    +    /**
    +    * @property {Phaser.Physics.P2.Body} body - The P2 Body to display debug data for.
    +    */
    +    this.body = body;
    +
    +    /**
    +    * @property {Phaser.Graphics} canvas - The canvas to render the debug info to.
    +    */
    +    this.canvas = new Phaser.Graphics(game);
    +
    +    this.canvas.alpha = this.settings.alpha
    +
    +    this.add(this.canvas);
    +
    +    this.draw();
    +
    +}
    +
    +Phaser.Physics.P2.BodyDebug.prototype = Object.create(Phaser.Group.prototype)
    +Phaser.Physics.P2.BodyDebug.prototype.constructor = Phaser.Physics.P2.BodyDebug
    +
    +Phaser.Utils.extend(Phaser.Physics.P2.BodyDebug.prototype, {
    +
    +    /**
    +    * Core update.
    +    *
    +    * @method Phaser.Physics.P2.BodyDebug#update
    +    */
    +    update: function() {
    +
    +        this.updateSpriteTransform();
    +
    +    },
    +
    +    /**
    +    * Core update.
    +    *
    +    * @method Phaser.Physics.P2.BodyDebug#updateSpriteTransform
    +    */
    +    updateSpriteTransform: function() {
    +
    +        this.position.x = this.body.position[0] * this.ppu;
    +        this.position.y = this.body.position[1] * this.ppu;
    +
    +        return this.rotation = this.body.angle;
    +
    +    },
    +
    +    /**
    +    * Draws the P2 shapes to the Graphics object.
    +    *
    +    * @method Phaser.Physics.P2.BodyDebug#draw
    +    */
    +    draw: function() {
    +    
    +        var angle, child, color, i, j, lineColor, lw, obj, offset, sprite, v, verts, vrot, _j, _ref1;
    +        obj = this.body;
    +        sprite = this.canvas;
    +        sprite.clear();
    +        color = parseInt(this.randomPastelHex(), 16);
    +        lineColor = 0xff0000;
    +        lw = this.lineWidth;
    +
    +        if (obj instanceof p2.Body && obj.shapes.length)
    +        {
    +            var l = obj.shapes.length
    +
    +            i = 0;
    +            
    +            while (i !== l)
    +            {
    +                child = obj.shapes[i];
    +                offset = obj.shapeOffsets[i];
    +                angle = obj.shapeAngles[i];
    +                offset = offset || 0;
    +                angle = angle || 0;
    +        
    +                if (child instanceof p2.Circle)
    +                {
    +                    this.drawCircle(sprite, offset[0] * this.ppu, -offset[1] * this.ppu, angle, child.radius * this.ppu, color, lw);
    +                }
    +                else if (child instanceof p2.Convex)
    +                {
    +                    verts = [];
    +                    vrot = p2.vec2.create();
    +
    +                    for (j = _j = 0, _ref1 = child.vertices.length; 0 <= _ref1 ? _j < _ref1 : _j > _ref1; j = 0 <= _ref1 ? ++_j : --_j)
    +                    {
    +                        v = child.vertices[j];
    +                        p2.vec2.rotate(vrot, v, angle);
    +                        verts.push([(vrot[0] + offset[0]) * this.ppu, -(vrot[1] + offset[1]) * this.ppu]);
    +                    }
    +
    +                    this.drawConvex(sprite, verts, child.triangles, lineColor, color, lw, this.settings.debugPolygons, [offset[0] * this.ppu, -offset[1] * this.ppu]);
    +                }
    +                else if (child instanceof p2.Plane)
    +                {
    +                    this.drawPlane(sprite, offset[0] * this.ppu, -offset[1] * this.ppu, color, lineColor, lw * 5, lw * 10, lw * 10, this.ppu * 100, angle);
    +                }
    +                else if (child instanceof p2.Line)
    +                {
    +                    this.drawLine(sprite, child.length * this.ppu, lineColor, lw);
    +                }
    +                else if (child instanceof p2.Rectangle)
    +                {
    +                    this.drawRectangle(sprite, offset[0] * this.ppu, -offset[1] * this.ppu, angle, child.width * this.ppu, child.height * this.ppu, lineColor, color, lw);
    +                }
    +
    +                i++
    +            }
    +        }
    +
    +    },
    +
    +    /**
    +    * Draws the P2 shapes to the Graphics object.
    +    *
    +    * @method Phaser.Physics.P2.BodyDebug#draw
    +    */
    +    drawRectangle: function(g, x, y, angle, w, h, color, fillColor, lineWidth) {
    +
    +        if (typeof lineWidth === 'undefined') { lineWidth = 1; }
    +        if (typeof color === 'undefined') { color = 0x000000; }
    +
    +        g.lineStyle(lineWidth, color, 1);
    +        g.beginFill(fillColor);
    +        g.drawRect(x - w / 2, y - h / 2, w, h);
    +
    +    },
    +
    +    /**
    +    * Draws a P2 Circle shape.
    +    *
    +    * @method Phaser.Physics.P2.BodyDebug#drawCircle
    +    */
    +    drawCircle: function(g, x, y, angle, radius, color, lineWidth) {
    +
    +        if (typeof lineWidth === 'undefined') { lineWidth = 1; }
    +        if (typeof color === 'undefined') { color = 0xffffff; }
    +        g.lineStyle(lineWidth, 0x000000, 1);
    +        g.beginFill(color, 1.0);
    +        g.drawCircle(x, y, -radius);
    +        g.endFill();
    +        g.moveTo(x, y);
    +        g.lineTo(x + radius * Math.cos(-angle), y + radius * Math.sin(-angle));
    +
    +    },
    +
    +    /**
    +    * Draws a P2 Line shape.
    +    *
    +    * @method Phaser.Physics.P2.BodyDebug#drawCircle
    +    */
    +    drawLine: function(g, len, color, lineWidth) {
    +
    +        if (typeof lineWidth === 'undefined') { lineWidth = 1; }
    +        if (typeof color === 'undefined') { color = 0x000000; }
    +
    +        g.lineStyle(lineWidth * 5, color, 1);
    +        g.moveTo(-len / 2, 0);
    +        g.lineTo(len / 2, 0);
    +
    +    },
    +
    +    /**
    +    * Draws a P2 Convex shape.
    +    *
    +    * @method Phaser.Physics.P2.BodyDebug#drawConvex
    +    */
    +    drawConvex: function(g, verts, triangles, color, fillColor, lineWidth, debug, offset) {
    +
    +        var colors, i, v, v0, v1, x, x0, x1, y, y0, y1;
    +
    +        if (typeof lineWidth === 'undefined') { lineWidth = 1; }
    +        if (typeof color === 'undefined') { color = 0x000000; }
    +
    +        if (!debug)
    +        {
    +            g.lineStyle(lineWidth, color, 1);
    +            g.beginFill(fillColor);
    +            i = 0;
    +
    +            while (i !== verts.length)
    +            {
    +                v = verts[i];
    +                x = v[0];
    +                y = v[1];
    +
    +                if (i === 0)
    +                {
    +                    g.moveTo(x, -y);
    +                }
    +                else
    +                {
    +                    g.lineTo(x, -y);
    +                }
    +
    +                i++;
    +            }
    +
    +            g.endFill();
    +
    +            if (verts.length > 2)
    +            {
    +                g.moveTo(verts[verts.length - 1][0], -verts[verts.length - 1][1]);
    +                return g.lineTo(verts[0][0], -verts[0][1]);
    +            }
    +        }
    +        else
    +        {
    +            colors = [0xff0000, 0x00ff00, 0x0000ff];
    +            i = 0;
    +         
    +            while (i !== verts.length + 1)
    +            {
    +                v0 = verts[i % verts.length];
    +                v1 = verts[(i + 1) % verts.length];
    +                x0 = v0[0];
    +                y0 = v0[1];
    +                x1 = v1[0];
    +                y1 = v1[1];
    +                g.lineStyle(lineWidth, colors[i % colors.length], 1);
    +                g.moveTo(x0, -y0);
    +                g.lineTo(x1, -y1);
    +                g.drawCircle(x0, -y0, lineWidth * 2);
    +                i++;
    +            }
    +
    +            g.lineStyle(lineWidth, 0x000000, 1);
    +            return g.drawCircle(offset[0], offset[1], lineWidth * 2);
    +        }
    +
    +    },
    +
    +    /**
    +    * Draws a P2 Path.
    +    *
    +    * @method Phaser.Physics.P2.BodyDebug#drawPath
    +    */
    +    drawPath: function(g, path, color, fillColor, lineWidth) {
    +
    +        var area, i, lastx, lasty, p1x, p1y, p2x, p2y, p3x, p3y, v, x, y;
    +        if (typeof lineWidth === 'undefined') { lineWidth = 1; }
    +        if (typeof color === 'undefined') { color = 0x000000; }
    +
    +        g.lineStyle(lineWidth, color, 1);
    +
    +        if (typeof fillColor === "number")
    +        {
    +            g.beginFill(fillColor);
    +        }
    +
    +        lastx = null;
    +        lasty = null;
    +        i = 0;
    +
    +        while (i < path.length)
    +        {
    +            v = path[i];
    +            x = v[0];
    +            y = v[1];
    +
    +            if (x !== lastx || y !== lasty)
    +            {
    +                if (i === 0)
    +                {
    +                    g.moveTo(x, y);
    +                }
    +                else
    +                {
    +                    p1x = lastx;
    +                    p1y = lasty;
    +                    p2x = x;
    +                    p2y = y;
    +                    p3x = path[(i + 1) % path.length][0];
    +                    p3y = path[(i + 1) % path.length][1];
    +                    area = ((p2x - p1x) * (p3y - p1y)) - ((p3x - p1x) * (p2y - p1y));
    +
    +                    if (area !== 0)
    +                    {
    +                        g.lineTo(x, y);
    +                    }
    +                }
    +                lastx = x;
    +                lasty = y;
    +            }
    +
    +            i++;
    +
    +        }
    +
    +        if (typeof fillColor === "number")
    +        {
    +            g.endFill();
    +        }
    +
    +        if (path.length > 2 && typeof fillColor === "number")
    +        {
    +            g.moveTo(path[path.length - 1][0], path[path.length - 1][1]);
    +            g.lineTo(path[0][0], path[0][1]);
    +        }
    +
    +    },
    +
    +    /**
    +    * Draws a P2 Plane shape.
    +    *
    +    * @method Phaser.Physics.P2.BodyDebug#drawPlane
    +    */
    +    drawPlane: function(g, x0, x1, color, lineColor, lineWidth, diagMargin, diagSize, maxLength, angle) {
    +
    +        var max, xd, yd;
    +        if (typeof lineWidth === 'undefined') { lineWidth = 1; }
    +        if (typeof color === 'undefined') { color = 0xffffff; }
    +
    +        g.lineStyle(lineWidth, lineColor, 11);
    +        g.beginFill(color);
    +        max = maxLength;
    +
    +        g.moveTo(x0, -x1);
    +        xd = x0 + Math.cos(angle) * this.game.width;
    +        yd = x1 + Math.sin(angle) * this.game.height;
    +        g.lineTo(xd, -yd);
    +
    +        g.moveTo(x0, -x1);
    +        xd = x0 + Math.cos(angle) * -this.game.width;
    +        yd = x1 + Math.sin(angle) * -this.game.height;
    +        g.lineTo(xd, -yd);
    +
    +    },
    +
    +    /**
    +    * Picks a random pastel color.
    +    *
    +    * @method Phaser.Physics.P2.BodyDebug#randomPastelHex
    +    */
    +    randomPastelHex: function() {
    +
    +        var blue, green, mix, red;
    +        mix = [255, 255, 255];
    +
    +        red = Math.floor(Math.random() * 256);
    +        green = Math.floor(Math.random() * 256);
    +        blue = Math.floor(Math.random() * 256);
    +
    +        red = Math.floor((red + 3 * mix[0]) / 4);
    +        green = Math.floor((green + 3 * mix[1]) / 4);
    +        blue = Math.floor((blue + 3 * mix[2]) / 4);
    +
    +        return this.rgbToHex(red, green, blue);
    +
    +    },
    +
    +    /**
    +    * Converts from RGB to Hex.
    +    *
    +    * @method Phaser.Physics.P2.BodyDebug#rgbToHex
    +    */
    +    rgbToHex: function(r, g, b) {
    +        return this.componentToHex(r) + this.componentToHex(g) + this.componentToHex(b);
    +    },
    +
    +    /**
    +    * Component to hex conversion.
    +    *
    +    * @method Phaser.Physics.P2.BodyDebug#componentToHex
    +    */
    +    componentToHex: function(c) {
    +
    +        var hex;
    +        hex = c.toString(16);
    +
    +        if (hex.len === 2)
    +        {
    +            return hex;
    +        }
    +        else
    +        {
    +            return hex + '0';
    +        }
    +
    +    }
    +
    +})
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2014 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Mar 14 2014 06:34:18 GMT-0000 (GMT) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/Button.js.html b/docs/Button.js.html index 12655a41c2..4f81cc20b9 100644 --- a/docs/Button.js.html +++ b/docs/Button.js.html @@ -58,10 +58,6 @@ BitmapData -
  • - BitmapFont -
  • -
  • BitmapText
  • @@ -259,35 +255,83 @@
  • - Body + Body +
  • + +
  • + Ninja +
  • + +
  • + AABB +
  • + +
  • + Body +
  • + +
  • + Circle +
  • + +
  • + Tile +
  • + +
  • + P2 +
  • + +
  • + Body +
  • + +
  • + BodyDebug +
  • + +
  • + CollisionGroup +
  • + +
  • + ContactMaterial +
  • + +
  • + DistanceConstraint +
  • + +
  • + GearConstraint
  • - CollisionGroup + InversePointProxy
  • - ContactMaterial + LockConstraint
  • - InversePointProxy + Material
  • - Material + PointProxy
  • - PointProxy + PrismaticConstraint
  • - Spring + RevoluteConstraint
  • - World + Spring
  • @@ -310,6 +354,10 @@ Polygon
  • +
  • + QuadTree +
  • +
  • RandomDataGenerator
  • @@ -326,6 +374,14 @@ RequestAnimationFrame +
  • + RetroFont +
  • + +
  • + ScaleManager +
  • +
  • Signal
  • @@ -354,10 +410,6 @@ Stage -
  • - StageScaleMode -
  • -
  • State
  • @@ -438,40 +490,6 @@ - - @@ -1147,7 +1165,7 @@

    Source: gameobjects/Button.js

    Documentation generated by JSDoc 3.3.0-dev - on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template. + on Fri Mar 14 2014 06:34:17 GMT-0000 (GMT) using the DocStrap template. @@ -1174,6 +1192,9 @@

    Source: gameobjects/Button.js

    + + + + + + + + + + + + + + + + + + + diff --git a/docs/CollisionGroup.js.html b/docs/CollisionGroup.js.html index c65f9550f2..14de82da86 100644 --- a/docs/CollisionGroup.js.html +++ b/docs/CollisionGroup.js.html @@ -3,7 +3,7 @@ - Phaser Source: physics/CollisionGroup.js + Phaser Source: physics/p2/CollisionGroup.js + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: physics/p2/DistanceConstraint.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2014 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* A constraint that tries to keep the distance between two bodies constant.
    +*
    +* @class Phaser.Physics.P2.DistanceConstraint
    +* @classdesc Physics DistanceConstraint Constructor
    +* @constructor
    +* @param {Phaser.Physics.P2} world - A reference to the P2 World.
    +* @param {p2.Body} bodyA - First connected body.
    +* @param {p2.Body} bodyB - Second connected body.
    +* @param {number} distance - The distance to keep between the bodies.
    +* @param {number} [maxForce] - The maximum force that should be applied to constrain the bodies.
    +*/
    +Phaser.Physics.P2.DistanceConstraint = function (world, bodyA, bodyB, distance, maxForce) {
    +
    +    if (typeof distance === 'undefined') { distance = 100; }
    +
    +    /**
    +    * @property {Phaser.Game} game - Local reference to game.
    +    */
    +    this.game = world.game;
    +
    +    /**
    +    * @property {Phaser.Physics.P2} world - Local reference to P2 World.
    +    */
    +    this.world = world;
    +
    +    distance = world.pxm(distance);
    +
    +    p2.DistanceConstraint.call(this, bodyA, bodyB, distance, maxForce);
    +
    +}
    +
    +Phaser.Physics.P2.DistanceConstraint.prototype = Object.create(p2.DistanceConstraint.prototype);
    +Phaser.Physics.P2.DistanceConstraint.prototype.constructor = Phaser.Physics.P2.DistanceConstraint;
    +
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2014 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Mar 14 2014 06:34:18 GMT-0000 (GMT) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/Easing.js.html b/docs/Easing.js.html index f316751e24..376d0cf923 100644 --- a/docs/Easing.js.html +++ b/docs/Easing.js.html @@ -58,10 +58,6 @@ BitmapData -
  • - BitmapFont -
  • -
  • BitmapText
  • @@ -259,35 +255,83 @@
  • - Body + Body
  • - CollisionGroup + Ninja
  • - ContactMaterial + AABB
  • - InversePointProxy + Body
  • - Material + Circle
  • - PointProxy + Tile
  • - Spring + P2
  • - World + Body +
  • + +
  • + BodyDebug +
  • + +
  • + CollisionGroup +
  • + +
  • + ContactMaterial +
  • + +
  • + DistanceConstraint +
  • + +
  • + GearConstraint +
  • + +
  • + InversePointProxy +
  • + +
  • + LockConstraint +
  • + +
  • + Material +
  • + +
  • + PointProxy +
  • + +
  • + PrismaticConstraint +
  • + +
  • + RevoluteConstraint +
  • + +
  • + Spring
  • @@ -310,6 +354,10 @@ Polygon
  • +
  • + QuadTree +
  • +
  • RandomDataGenerator
  • @@ -326,6 +374,14 @@ RequestAnimationFrame +
  • + RetroFont +
  • + +
  • + ScaleManager +
  • +
  • Signal
  • @@ -354,10 +410,6 @@ Stage -
  • - StageScaleMode -
  • -
  • State
  • @@ -438,40 +490,6 @@ - - @@ -856,11 +874,11 @@

    Source: tween/Easing.js

    /** * Circular ease-in/out. - * + * * @method Phaser.Easing.Circular#InOut * @param {number} k - The value to be tweened. * @returns {number} The tweened value. - */ + */ InOut: function ( k ) { if ( ( k *= 2 ) < 1) return - 0.5 * ( Math.sqrt( 1 - k * k) - 1); @@ -879,11 +897,11 @@

    Source: tween/Easing.js

    /** * Elastic ease-in. - * + * * @method Phaser.Easing.Elastic#In * @param {number} k - The value to be tweened. * @returns {number} The tweened value. - */ + */ In: function ( k ) { var s, a = 0.1, p = 0.4; @@ -897,11 +915,11 @@

    Source: tween/Easing.js

    /** * Elastic ease-out. - * + * * @method Phaser.Easing.Elastic#Out * @param {number} k - The value to be tweened. * @returns {number} The tweened value. - */ + */ Out: function ( k ) { var s, a = 0.1, p = 0.4; @@ -915,11 +933,11 @@

    Source: tween/Easing.js

    /** * Elastic ease-in/out. - * + * * @method Phaser.Easing.Elastic#InOut * @param {number} k - The value to be tweened. * @returns {number} The tweened value. - */ + */ InOut: function ( k ) { var s, a = 0.1, p = 0.4; @@ -943,11 +961,11 @@

    Source: tween/Easing.js

    /** * Back ease-in. - * + * * @method Phaser.Easing.Back#In * @param {number} k - The value to be tweened. * @returns {number} The tweened value. - */ + */ In: function ( k ) { var s = 1.70158; @@ -957,11 +975,11 @@

    Source: tween/Easing.js

    /** * Back ease-out. - * + * * @method Phaser.Easing.Back#Out * @param {number} k - The value to be tweened. * @returns {number} The tweened value. - */ + */ Out: function ( k ) { var s = 1.70158; @@ -971,11 +989,11 @@

    Source: tween/Easing.js

    /** * Back ease-in/out. - * + * * @method Phaser.Easing.Back#InOut * @param {number} k - The value to be tweened. * @returns {number} The tweened value. - */ + */ InOut: function ( k ) { var s = 1.70158 * 1.525; @@ -995,11 +1013,11 @@

    Source: tween/Easing.js

    /** * Bounce ease-in. - * + * * @method Phaser.Easing.Bounce#In * @param {number} k - The value to be tweened. * @returns {number} The tweened value. - */ + */ In: function ( k ) { return 1 - Phaser.Easing.Bounce.Out( 1 - k ); @@ -1008,11 +1026,11 @@

    Source: tween/Easing.js

    /** * Bounce ease-out. - * + * * @method Phaser.Easing.Bounce#Out * @param {number} k - The value to be tweened. * @returns {number} The tweened value. - */ + */ Out: function ( k ) { if ( k < ( 1 / 2.75 ) ) { @@ -1037,11 +1055,11 @@

    Source: tween/Easing.js

    /** * Bounce ease-in/out. - * + * * @method Phaser.Easing.Bounce#InOut * @param {number} k - The value to be tweened. * @returns {number} The tweened value. - */ + */ InOut: function ( k ) { if ( k < 0.5 ) return Phaser.Easing.Bounce.In( k * 2 ) * 0.5; @@ -1073,7 +1091,7 @@

    Source: tween/Easing.js

    Documentation generated by JSDoc 3.3.0-dev - on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template. + on Fri Mar 14 2014 06:34:17 GMT-0000 (GMT) using the DocStrap template. @@ -1100,6 +1118,9 @@

    Source: tween/Easing.js

    + + + + + + + + + + + + + + + + + + + diff --git a/docs/Graphics.js.html b/docs/Graphics.js.html index 9f98156ed1..d919e8bce3 100644 --- a/docs/Graphics.js.html +++ b/docs/Graphics.js.html @@ -58,10 +58,6 @@ BitmapData -
  • - BitmapFont -
  • -
  • BitmapText
  • @@ -259,35 +255,83 @@
  • - Body + Body
  • - CollisionGroup + Ninja
  • - ContactMaterial + AABB
  • - InversePointProxy + Body
  • - Material + Circle
  • - PointProxy + Tile
  • - Spring + P2
  • - World + Body +
  • + +
  • + BodyDebug +
  • + +
  • + CollisionGroup +
  • + +
  • + ContactMaterial +
  • + +
  • + DistanceConstraint +
  • + +
  • + GearConstraint +
  • + +
  • + InversePointProxy +
  • + +
  • + LockConstraint +
  • + +
  • + Material +
  • + +
  • + PointProxy +
  • + +
  • + PrismaticConstraint +
  • + +
  • + RevoluteConstraint +
  • + +
  • + Spring
  • @@ -310,6 +354,10 @@ Polygon
  • +
  • + QuadTree +
  • +
  • RandomDataGenerator
  • @@ -326,6 +374,14 @@ RequestAnimationFrame +
  • + RetroFont +
  • + +
  • + ScaleManager +
  • +
  • Signal
  • @@ -354,10 +410,6 @@ Stage -
  • - StageScaleMode -
  • -
  • State
  • @@ -438,40 +490,6 @@ - - @@ -533,6 +551,11 @@

    Source: gameobjects/Graphics.js

    */ this.type = Phaser.GRAPHICS; + /** + * @property {number} z - The z-depth value of this object within its Group (remember the World is a Group as well). No two objects in a Group can have the same z value. + */ + this.z = 0; + /** * @property {Phaser.Point} world - The world coordinates of this Sprite. This differs from the x/y coordinates which are relative to the Sprites container. */ @@ -593,7 +616,7 @@

    Source: gameobjects/Graphics.js

    if (this.visible) { - this._cache[3] = this.game.world.currentRenderOrderID++; + this._cache[3] = this.game.stage.currentRenderOrderID++; } return true; @@ -619,8 +642,8 @@

    Source: gameobjects/Graphics.js

    // Fixed to Camera? if (this._cache[7] === 1) { - this.position.x = this.game.camera.view.x + this.cameraOffset.x; - this.position.y = this.game.camera.view.y + this.cameraOffset.y; + this.position.x = (this.game.camera.view.x + this.cameraOffset.x) / this.game.camera.scale.x; + this.position.y = (this.game.camera.view.y + this.cameraOffset.y) / this.game.camera.scale.y; } } @@ -629,14 +652,41 @@

    Source: gameobjects/Graphics.js

    * Destroy this Graphics instance. * * @method Phaser.Graphics.prototype.destroy +* @param {boolean} [destroyChildren=true] - Should every child of this object have its destroy method called? */ -Phaser.Graphics.prototype.destroy = function() { +Phaser.Graphics.prototype.destroy = function(destroyChildren) { + + if (typeof destroyChildren === 'undefined') { destroyChildren = true; } this.clear(); if (this.parent) { - this.parent.remove(this); + if (this.parent instanceof Phaser.Group) + { + this.parent.remove(this); + } + else + { + this.parent.removeChild(this); + } + } + + var i = this.children.length; + + if (destroyChildren) + { + while (i--) + { + this.children[i].destroy(destroyChildren); + } + } + else + { + while (i--) + { + this.removeChild(this.children[i]); + } } this.exists = false; @@ -734,7 +784,7 @@

    Source: gameobjects/Graphics.js

    Documentation generated by JSDoc 3.3.0-dev - on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template. + on Fri Mar 14 2014 06:34:17 GMT-0000 (GMT) using the DocStrap template. @@ -761,6 +811,9 @@

    Source: gameobjects/Graphics.js

    + + + + + + + + + + + + + + + + + + + diff --git a/docs/MSPointer.js.html b/docs/MSPointer.js.html index a7ce4f6bc3..4236653e6a 100644 --- a/docs/MSPointer.js.html +++ b/docs/MSPointer.js.html @@ -58,10 +58,6 @@ BitmapData -
  • - BitmapFont -
  • -
  • BitmapText
  • @@ -259,35 +255,83 @@
  • - Body + Body +
  • + +
  • + Ninja +
  • + +
  • + AABB +
  • + +
  • + Body +
  • + +
  • + Circle +
  • + +
  • + Tile +
  • + +
  • + P2 +
  • + +
  • + Body +
  • + +
  • + BodyDebug +
  • + +
  • + CollisionGroup +
  • + +
  • + ContactMaterial +
  • + +
  • + DistanceConstraint +
  • + +
  • + GearConstraint
  • - CollisionGroup + InversePointProxy
  • - ContactMaterial + LockConstraint
  • - InversePointProxy + Material
  • - Material + PointProxy
  • - PointProxy + PrismaticConstraint
  • - Spring + RevoluteConstraint
  • - World + Spring
  • @@ -310,6 +354,10 @@ Polygon
  • +
  • + QuadTree +
  • +
  • RandomDataGenerator
  • @@ -326,6 +374,14 @@ RequestAnimationFrame +
  • + RetroFont +
  • + +
  • + ScaleManager +
  • +
  • Signal
  • @@ -354,10 +410,6 @@ Stage -
  • - StageScaleMode -
  • -
  • State
  • @@ -438,40 +490,6 @@ - - @@ -680,7 +698,7 @@

    Source: input/MSPointer.js

    Documentation generated by JSDoc 3.3.0-dev - on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template. + on Fri Mar 14 2014 06:34:17 GMT-0000 (GMT) using the DocStrap template. @@ -707,6 +725,9 @@

    Source: input/MSPointer.js

    + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.Physics.Ninja.Body.html b/docs/Phaser.Physics.Ninja.Body.html new file mode 100644 index 0000000000..ce724bea1a --- /dev/null +++ b/docs/Phaser.Physics.Ninja.Body.html @@ -0,0 +1,4598 @@ + + + + + + Phaser Class: Body + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: Body

    +
    + +
    +

    + Phaser.Physics.Ninja. + + Body +

    + +

    Ninja Physics Body Constructor

    + +
    + +
    +
    + + + + +
    +

    new Body(system, sprite, type, id, radius, x, y, width, height)

    + + +
    +
    + + +
    +

    The Physics Body is linked to a single Sprite. All physics operations should be performed against the body rather than +the Sprite itself. For example you can set the velocity, bounce values etc all on the Body.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    system + + +Phaser.Physics.Ninja + + + + + + + + + + + +

    The physics system this Body belongs to.

    sprite + + +Phaser.Sprite + + + + + + + + + + + +

    The Sprite object this physics body belongs to.

    type + + +number + + + + + + <optional>
    + + + + + +
    + + 1 + +

    The type of Ninja shape to create. 1 = AABB, 2 = Circle or 3 = Tile.

    id + + +number + + + + + + <optional>
    + + + + + +
    + + 1 + +

    If this body is using a Tile shape, you can set the Tile id here, i.e. Phaser.Physics.Ninja.Tile.SLOPE_45DEGpn, Phaser.Physics.Ninja.Tile.CONVEXpp, etc.

    radius + + +number + + + + + + <optional>
    + + + + + +
    + + 16 + +

    If this body is using a Circle shape this controls the radius.

    x + + +number + + + + + + <optional>
    + + + + + +
    + + 0 + +

    The x coordinate of this Body. This is only used if a sprite is not provided.

    y + + +number + + + + + + <optional>
    + + + + + +
    + + 0 + +

    The y coordinate of this Body. This is only used if a sprite is not provided.

    width + + +number + + + + + + <optional>
    + + + + + +
    + + 0 + +

    The width of this Body. This is only used if a sprite is not provided.

    height + + +number + + + + + + <optional>
    + + + + + +
    + + 0 + +

    The height of this Body. This is only used if a sprite is not provided.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + +

    Members

    + +
    + +
    +

    aabb

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    aabb + + +Phaser.Physics.Ninja.AABB + + + +

    The AABB object this body is using for collision.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <readonly> angle

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    angle + + +number + + + +

    The angle of this Body

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <readonly> bottom

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    bottom + + +number + + + +

    The bottom value of this Body (same as Body.y + Body.height)

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    bounce

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    bounce + + +number + + + +

    The bounciness of this object when it collides. A value between 0 and 1. We recommend setting it to 0.999 to avoid jittering.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 0.3
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    checkCollision

    + + +
    +
    + +
    +

    Set the checkCollision properties to control which directions collision is processed for this Body. +For example checkCollision.up = false means it won't collide when the collision happened while moving up.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    checkCollision + + +object + + + +

    An object containing allowed collision.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    circle

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    circle + + +Phaser.Physics.Ninja.Circle + + + +

    The Circle object this body is using for collision.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    collideWorldBounds

    + + +
    +
    + +
    +

    A Body can be set to collide against the World bounds automatically and rebound back into the World if this is set to true. Otherwise it will leave the World.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    collideWorldBounds + + +boolean + + + +

    Should the Body collide with the World bounds?

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    drag

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    drag + + +number + + + +

    The drag applied to this object as it moves.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 1
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    facing

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    facing + + +number + + + +

    A const reference to the direction the Body is traveling or facing.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    friction

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    friction + + +number + + + +

    The friction applied to this object as it moves.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 0.05
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    game

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    Local reference to game.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    gravityScale

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    gravityScale + + +number + + + +

    How much of the world gravity should be applied to this object? 1 = all of it, 0.5 = 50%, etc.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 1
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <readonly> height

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    height + + +number + + + +

    The height of this Body

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    immovable

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    immovable + + +boolean + + + +

    An immovable Body will not receive any impacts from other bodies. Not fully implemented.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    maxSpeed

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    maxSpeed + + +number + + + +

    The maximum speed this body can travel at (taking drag and friction into account)

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 8
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    + + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    right + + +number + + + +

    The right value of this Body (same as Body.x + Body.width)

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    shape

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    shape + + +object + + + +

    A local reference to the body shape.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <readonly> speed

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    speed + + +number + + + +

    The speed of this Body

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    sprite

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    sprite + + +Phaser.Sprite + + + +

    Reference to the parent Sprite.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    system

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    system + + +Phaser.Physics.Ninja + + + +

    The parent physics system.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    tile

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    tile + + +Phaser.Physics.Ninja.Tile + + + +

    The Tile object this body is using for collision.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    touching

    + + +
    +
    + +
    +

    This object is populated with boolean values when the Body collides with another. +touching.up = true means the collision happened to the top of this Body for example.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    touching + + +object + + + +

    An object containing touching results.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    type

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    type + + +number + + + +

    The type of physics system this body belongs to.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    velocity

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    velocity + + +Phaser.Point + + + +

    The velocity in pixels per second sq. of the Body.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    wasTouching

    + + +
    +
    + +
    +

    This object is populated with previous touching values from the bodies previous collision.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    wasTouching + + +object + + + +

    An object containing previous touching results.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <readonly> width

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    width + + +number + + + +

    The width of this Body

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    x

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    x + + +number + + + +

    The x position.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    y

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    y + + +number + + + +

    The y position.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + +
    + + + +

    Methods

    + +
    + +
    +

    deltaAbsX() → {number}

    + + +
    +
    + + +
    +

    Returns the absolute delta x value.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The absolute delta value.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    deltaAbsY() → {number}

    + + +
    +
    + + +
    +

    Returns the absolute delta y value.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The absolute delta value.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    deltaX() → {number}

    + + +
    +
    + + +
    +

    Returns the delta x value. The difference between Body.x now and in the previous step.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The delta value. Positive if the motion was to the right, negative if to the left.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    deltaY() → {number}

    + + +
    +
    + + +
    +

    Returns the delta y value. The difference between Body.y now and in the previous step.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The delta value. Positive if the motion was downwards, negative if upwards.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    <protected> postUpdate()

    + + +
    +
    + + +
    +

    Internal method.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    <protected> preUpdate()

    + + +
    +
    + + +
    +

    Internal method.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    reset()

    + + +
    +
    + + +
    +

    Resets all Body values and repositions on the Sprite.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    setZeroVelocity()

    + + +
    +
    + + +
    +

    Stops all movement of this body.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2014 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Mar 14 2014 06:34:28 GMT-0000 (GMT) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.Physics.Ninja.Circle.html b/docs/Phaser.Physics.Ninja.Circle.html new file mode 100644 index 0000000000..2a3f67cc61 --- /dev/null +++ b/docs/Phaser.Physics.Ninja.Circle.html @@ -0,0 +1,4978 @@ + + + + + + Phaser Class: Circle + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: Circle

    +
    + +
    +

    + Phaser.Physics.Ninja. + + Circle +

    + +

    Arcade Physics Constructor

    + +
    + +
    +
    + + + + +
    +

    new Circle(body, x, y, radius)

    + + +
    +
    + + +
    +

    Ninja Physics Circle constructor. +Note: This class could be massively optimised and reduced in size. I leave that challenge up to you.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    body + + +Phaser.Physics.Ninja.Body + + + +

    The body that owns this shape.

    x + + +number + + + +

    The x coordinate to create this shape at.

    y + + +number + + + +

    The y coordinate to create this shape at.

    radius + + +number + + + +

    The radius of this Circle.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + +

    Members

    + +
    + +
    +

    body

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    system + + +Phaser.Physics.Ninja.Body + + + +

    A reference to the body that owns this shape.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    circleTileProjections

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    circleTileProjections + + +object + + + +

    All of the collision response handlers.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <readonly> height

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    height + + +number + + + +

    The height.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    oldpos

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    oldpos + + +Phaser.Point + + + +

    The position of this object in the previous update.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    pos

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pos + + +Phaser.Point + + + +

    The position of this object.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    radius

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    radius + + +number + + + +

    The radius of this circle shape.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    system

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    system + + +Phaser.Physics.Ninja + + + +

    A reference to the physics system.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    velocity

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    velocity + + +Phaser.Point + + + +

    The velocity of this object.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <readonly> width

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    width + + +number + + + +

    The width.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <readonly> xw

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    xw + + +number + + + +

    Half the width.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <readonly> yw

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    xw + + +number + + + +

    Half the height.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + +
    + + + +

    Methods

    + +
    + +
    +

    collideCircleVsTile(t) → {boolean}

    + + +
    +
    + + +
    +

    Collides this Circle with a Tile.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    t + + +Phaser.Physics.Ninja.Tile + + + +

    The Tile involved in the collision.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    True if they collide, otherwise false.

    +
    + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    collideWorldBounds()

    + + +
    +
    + + +
    +

    Collides this Circle against the world bounds.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    integrate()

    + + +
    +
    + + +
    +

    Updates this Circles position.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    projCircle_22DegB(x, y, oH, oV, obj, t) → {number}

    + + +
    +
    + + +
    +

    Resolves 22 Degree tile collision.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    x + + +number + + + +

    Penetration depth on the x axis.

    y + + +number + + + +

    Penetration depth on the y axis.

    oH + + +number + + + +

    Grid / voronoi region.

    oV + + +number + + + +

    Grid / voronoi region.

    obj + + +Phaser.Physics.Ninja.Circle + + + +

    The Circle involved in the collision.

    t + + +Phaser.Physics.Ninja.Tile + + + +

    The Tile involved in the collision.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The result of the collision.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    projCircle_22DegS(x, y, oH, oV, obj, t) → {number}

    + + +
    +
    + + +
    +

    Resolves 22 Degree tile collision.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    x + + +number + + + +

    Penetration depth on the x axis.

    y + + +number + + + +

    Penetration depth on the y axis.

    oH + + +number + + + +

    Grid / voronoi region.

    oV + + +number + + + +

    Grid / voronoi region.

    obj + + +Phaser.Physics.Ninja.Circle + + + +

    The Circle involved in the collision.

    t + + +Phaser.Physics.Ninja.Tile + + + +

    The Tile involved in the collision.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The result of the collision.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    projCircle_45Deg(x, y, oH, oV, obj, t) → {number}

    + + +
    +
    + + +
    +

    Resolves 45 Degree tile collision.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    x + + +number + + + +

    Penetration depth on the x axis.

    y + + +number + + + +

    Penetration depth on the y axis.

    oH + + +number + + + +

    Grid / voronoi region.

    oV + + +number + + + +

    Grid / voronoi region.

    obj + + +Phaser.Physics.Ninja.Circle + + + +

    The Circle involved in the collision.

    t + + +Phaser.Physics.Ninja.Tile + + + +

    The Tile involved in the collision.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The result of the collision.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    projCircle_67DegB(x, y, oH, oV, obj, t) → {number}

    + + +
    +
    + + +
    +

    Resolves 67 Degree tile collision.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    x + + +number + + + +

    Penetration depth on the x axis.

    y + + +number + + + +

    Penetration depth on the y axis.

    oH + + +number + + + +

    Grid / voronoi region.

    oV + + +number + + + +

    Grid / voronoi region.

    obj + + +Phaser.Physics.Ninja.Circle + + + +

    The Circle involved in the collision.

    t + + +Phaser.Physics.Ninja.Tile + + + +

    The Tile involved in the collision.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The result of the collision.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    projCircle_67DegS(x, y, oH, oV, obj, t) → {number}

    + + +
    +
    + + +
    +

    Resolves 67 Degree tile collision.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    x + + +number + + + +

    Penetration depth on the x axis.

    y + + +number + + + +

    Penetration depth on the y axis.

    oH + + +number + + + +

    Grid / voronoi region.

    oV + + +number + + + +

    Grid / voronoi region.

    obj + + +Phaser.Physics.Ninja.Circle + + + +

    The Circle involved in the collision.

    t + + +Phaser.Physics.Ninja.Tile + + + +

    The Tile involved in the collision.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The result of the collision.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    projCircle_Concave(x, y, oH, oV, obj, t) → {number}

    + + +
    +
    + + +
    +

    Resolves Concave tile collision.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    x + + +number + + + +

    Penetration depth on the x axis.

    y + + +number + + + +

    Penetration depth on the y axis.

    oH + + +number + + + +

    Grid / voronoi region.

    oV + + +number + + + +

    Grid / voronoi region.

    obj + + +Phaser.Physics.Ninja.Circle + + + +

    The Circle involved in the collision.

    t + + +Phaser.Physics.Ninja.Tile + + + +

    The Tile involved in the collision.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The result of the collision.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    projCircle_Convex(x, y, oH, oV, obj, t) → {number}

    + + +
    +
    + + +
    +

    Resolves Convex tile collision.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    x + + +number + + + +

    Penetration depth on the x axis.

    y + + +number + + + +

    Penetration depth on the y axis.

    oH + + +number + + + +

    Grid / voronoi region.

    oV + + +number + + + +

    Grid / voronoi region.

    obj + + +Phaser.Physics.Ninja.Circle + + + +

    The Circle involved in the collision.

    t + + +Phaser.Physics.Ninja.Tile + + + +

    The Tile involved in the collision.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The result of the collision.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    projCircle_Full(x, y, oH, oV, obj, t) → {number}

    + + +
    +
    + + +
    +

    Resolves Full tile collision.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    x + + +number + + + +

    Penetration depth on the x axis.

    y + + +number + + + +

    Penetration depth on the y axis.

    oH + + +number + + + +

    Grid / voronoi region.

    oV + + +number + + + +

    Grid / voronoi region.

    obj + + +Phaser.Physics.Ninja.Circle + + + +

    The Circle involved in the collision.

    t + + +Phaser.Physics.Ninja.Tile + + + +

    The Tile involved in the collision.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The result of the collision.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    projCircle_Half(x, y, oH, oV, obj, t) → {number}

    + + +
    +
    + + +
    +

    Resolves Half tile collision.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    x + + +number + + + +

    Penetration depth on the x axis.

    y + + +number + + + +

    Penetration depth on the y axis.

    oH + + +number + + + +

    Grid / voronoi region.

    oV + + +number + + + +

    Grid / voronoi region.

    obj + + +Phaser.Physics.Ninja.Circle + + + +

    The Circle involved in the collision.

    t + + +Phaser.Physics.Ninja.Tile + + + +

    The Tile involved in the collision.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The result of the collision.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    reportCollisionVsWorld(px, py, dx, dy, obj)

    + + +
    +
    + + +
    +

    Process a world collision and apply the resulting forces.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    px + + +number + + + +

    The tangent velocity

    py + + +number + + + +

    The tangent velocity

    dx + + +number + + + +

    Collision normal

    dy + + +number + + + +

    Collision normal

    obj + + +number + + + +

    Object this Circle collided with

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    resolveCircleTile(x, y, oH, oV, obj, t) → {number}

    + + +
    +
    + + +
    +

    Resolves tile collision.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    x + + +number + + + +

    Penetration depth on the x axis.

    y + + +number + + + +

    Penetration depth on the y axis.

    oH + + +number + + + +

    Grid / voronoi region.

    oV + + +number + + + +

    Grid / voronoi region.

    obj + + +Phaser.Physics.Ninja.Circle + + + +

    The Circle involved in the collision.

    t + + +Phaser.Physics.Ninja.Tile + + + +

    The Tile involved in the collision.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The result of the collision.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2014 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Mar 14 2014 06:34:28 GMT-0000 (GMT) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.Physics.Ninja.Tile.html b/docs/Phaser.Physics.Ninja.Tile.html new file mode 100644 index 0000000000..fddfac1d34 --- /dev/null +++ b/docs/Phaser.Physics.Ninja.Tile.html @@ -0,0 +1,3070 @@ + + + + + + Phaser Class: Tile + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: Tile

    +
    + +
    +

    + Phaser.Physics.Ninja. + + Tile +

    + +

    The Ninja Physics Tile class. Based on code by Metanet Software.

    + +
    + +
    +
    + + + + +
    +

    new Tile(body, x, y, width, height, type)

    + + +
    +
    + + +
    +

    Ninja Physics Tile constructor. +A Tile is defined by its width, height and type. It's type can include slope data, such as 45 degree slopes, or convex slopes. +Understand that for any type including a slope (types 2 to 29) the Tile must be SQUARE, i.e. have an equal width and height. +Also note that as Tiles are primarily used for levels they have gravity disabled and world bounds collision disabled by default.

    +

    Note: This class could be massively optimised and reduced in size. I leave that challenge up to you.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    body + + +Phaser.Physics.Ninja.Body + + + + + + + + + + + +

    The body that owns this shape.

    x + + +number + + + + + + + + + + + +

    The x coordinate to create this shape at.

    y + + +number + + + + + + + + + + + +

    The y coordinate to create this shape at.

    width + + +number + + + + + + + + + + + +

    The width of this AABB.

    height + + +number + + + + + + + + + + + +

    The height of this AABB.

    type + + +number + + + + + + <optional>
    + + + + + +
    + + 1 + +

    The type of Ninja shape to create. 1 = AABB, 2 = Circle or 3 = Tile.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + +

    Members

    + +
    + +
    +

    body

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    system + + +Phaser.Physics.Ninja.Body + + + +

    A reference to the body that owns this shape.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <readonly> bottom

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    bottom + + +number + + + +

    The bottom value of this Body (same as Body.y + Body.height)

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <readonly> height

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    height + + +number + + + +

    The height.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <readonly> id

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    id + + +number + + + +

    The ID of this Tile.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    oldpos

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    oldpos + + +Phaser.Point + + + +

    The position of this object in the previous update.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    pos

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pos + + +Phaser.Point + + + +

    The position of this object.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    + + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    right + + +number + + + +

    The right value of this Body (same as Body.x + Body.width)

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    system

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    system + + +Phaser.Physics.Ninja + + + +

    A reference to the physics system.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <readonly> type

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    type + + +number + + + +

    The type of this Tile.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    velocity

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    velocity + + +Phaser.Point + + + +

    The velocity of this object.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <readonly> width

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    width + + +number + + + +

    The width.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    x

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    x + + +number + + + +

    The x position.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <readonly> xw

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    xw + + +number + + + +

    Half the width.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    y

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    y + + +number + + + +

    The y position.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <readonly> yw

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    xw + + +number + + + +

    Half the height.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + +
    + + + +

    Methods

    + +
    + +
    +

    clear()

    + + +
    +
    + + +
    +

    Sets this tile to be empty.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    collideWorldBounds()

    + + +
    +
    + + +
    +

    Tiles cannot collide with the world bounds, it's up to you to keep them where you want them. But we need this API stub to satisfy the Body.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    destroy()

    + + +
    +
    + + +
    +

    Destroys this Tiles reference to Body and System.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    integrate()

    + + +
    +
    + + +
    +

    Updates this objects position.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    reportCollisionVsWorld(px, py, dx, dy, obj)

    + + +
    +
    + + +
    +

    Process a world collision and apply the resulting forces.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    px + + +number + + + +

    The tangent velocity

    py + + +number + + + +

    The tangent velocity

    dx + + +number + + + +

    Collision normal

    dy + + +number + + + +

    Collision normal

    obj + + +number + + + +

    Object this Tile collided with

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    setType(id)

    + + +
    +
    + + +
    +

    Tiles cannot collide with the world bounds, it's up to you to keep them where you want them. But we need this API stub to satisfy the Body.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    id + + +number + + + +

    The type of Tile this will use, i.e. Phaser.Physics.Ninja.Tile.SLOPE_45DEGpn, Phaser.Physics.Ninja.Tile.CONVEXpp, etc.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2014 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Mar 14 2014 06:34:28 GMT-0000 (GMT) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.Physics.Ninja.html b/docs/Phaser.Physics.Ninja.html new file mode 100644 index 0000000000..8b1422caaf --- /dev/null +++ b/docs/Phaser.Physics.Ninja.html @@ -0,0 +1,4093 @@ + + + + + + Phaser Class: Ninja + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: Ninja

    +
    + +
    +

    + Phaser.Physics. + + Ninja +

    + +

    Ninja Physics Constructor

    + +
    + +
    +
    + + + + +
    +

    new Ninja(game)

    + + +
    +
    + + +
    +

    Ninja Physics. The Ninja Physics system was created in Flash by Metanet Software and ported to JavaScript by Richard Davey.

    +

    It allows for AABB and Circle to Tile collision. Tiles can be any of 34 different types, including slopes, convex and concave shapes.

    +

    It does what it does very well, but is ripe for expansion and optimisation. Here are some features that I'd love to see the community add:

    +
      +
    • AABB to AABB collision
    • +
    • AABB to Circle collision
    • +
    • AABB and Circle 'immovable' property support
    • +
    • n-way collision, so an AABB/Circle could pass through a tile from below and land upon it.
    • +
    • QuadTree or spatial grid for faster Body vs. Tile Group look-ups.
    • +
    • Optimise the internal vector math and reduce the quantity of temporary vars created.
    • +
    • Expand Gravity and Bounce to allow for separate x/y axis values.
    • +
    • Support Bodies linked to Sprites that don't have anchor set to 0.5
    • +
    +

    Feel free to attempt any of the above and submit a Pull Request with your code! Be sure to include test cases proving they work.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    reference to the current game instance.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + +

    Classes

    + +
    +
    AABB
    +
    + +
    Body
    +
    + +
    Circle
    +
    + +
    Tile
    +
    +
    + + + + + +

    Members

    + +
    + +
    +

    bounds

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    bounds + + +Phaser.Rectangle + + + +

    The bounds inside of which the physics world exists. Defaults to match the world bounds.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    game

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    Local reference to game.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    gravity

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    gravity + + +number + + + +

    The World gravity setting.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    maxLevels

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    maxLevels + + +number + + + +

    Used by the QuadTree to set the maximum number of iteration levels.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    maxObjects

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    maxObjects + + +number + + + +

    Used by the QuadTree to set the maximum number of objects per quad.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    quadTree

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    quadTree + + +Phaser.QuadTree + + + +

    The world QuadTree.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    time

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    time + + +Phaser.Time + + + +

    Local reference to game.time.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + +
    + + + +

    Methods

    + +
    + +
    +

    clearTilemapLayerBodies(map, layer)

    + + +
    +
    + + +
    +

    Clears all physics bodies from the given TilemapLayer that were created with World.convertTilemap.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDescription
    map + + +Phaser.Tilemap + + + + + + + + + +

    The Tilemap to get the map data from.

    layer + + +number +| + +string +| + +Phaser.TilemapLayer + + + + + + <optional>
    + + + + + +

    The layer to operate on. If not given will default to map.currentLayer.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    collide(object1, object2, collideCallback, processCallback, callbackContext) → {boolean}

    + + +
    +
    + + +
    +

    Checks for collision between two game objects. You can perform Sprite vs. Sprite, Sprite vs. Group, Group vs. Group, Sprite vs. Tilemap Layer or Group vs. Tilemap Layer collisions. +The second parameter can be an array of objects, of differing types. +The objects are also automatically separated. If you don't require separation then use ArcadePhysics.overlap instead. +An optional processCallback can be provided. If given this function will be called when two sprites are found to be colliding. It is called before any separation takes place, +giving you the chance to perform additional checks. If the function returns true then the collision and separation is carried out. If it returns false it is skipped. +The collideCallback is an optional function that is only called if two sprites collide. If a processCallback has been set then it needs to return true for collideCallback to be called.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    object1 + + +Phaser.Sprite +| + +Phaser.Group +| + +Phaser.Particles.Emitter +| + +Phaser.Tilemap + + + + + + + + + + + +

    The first object to check. Can be an instance of Phaser.Sprite, Phaser.Group, Phaser.Particles.Emitter, or Phaser.Tilemap.

    object2 + + +Phaser.Sprite +| + +Phaser.Group +| + +Phaser.Particles.Emitter +| + +Phaser.Tilemap +| + +array + + + + + + + + + + + +

    The second object or array of objects to check. Can be Phaser.Sprite, Phaser.Group, Phaser.Particles.Emitter or Phaser.Tilemap.

    collideCallback + + +function + + + + + + <optional>
    + + + + + +
    + + null + +

    An optional callback function that is called if the objects collide. The two objects will be passed to this function in the same order in which you specified them.

    processCallback + + +function + + + + + + <optional>
    + + + + + +
    + + null + +

    A callback function that lets you perform additional checks against the two objects if they overlap. If this is set then collision will only happen if processCallback returns true. The two objects will be passed to this function in the same order in which you specified them.

    callbackContext + + +object + + + + + + <optional>
    + + + + + +
    + +

    The context in which to run the callbacks.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    True if a collision occured otherwise false.

    +
    + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    convertTilemap(map, layer, slopeMap) → {array}

    + + +
    +
    + + +
    +

    Goes through all tiles in the given Tilemap and TilemapLayer and converts those set to collide into physics tiles. +Only call this after you have specified all of the tiles you wish to collide with calls like Tilemap.setCollisionBetween, etc. +Every time you call this method it will destroy any previously created bodies and remove them from the world. +Therefore understand it's a very expensive operation and not to be done in a core game update loop.

    +

    In Ninja the Tiles have an ID from 0 to 33, where 0 is 'empty', 1 is a full tile, 2 is a 45-degree slope, etc. You can find the ID +list either at the very bottom of Tile.js, or in a handy visual reference in the resources/Ninja Physics Debug Tiles folder in the repository. +The slopeMap parameter is an array that controls how the indexes of the tiles in your tilemap data will map to the Ninja Tile IDs. +For example if you had 6 tiles in your tileset: Imagine the first 4 should be converted into fully solid Tiles and the other 2 are 45-degree slopes. +Your slopeMap array would look like this: [ 1, 1, 1, 1, 2, 3 ]. +Where each element of the array is a tile in your tilemap and the resulting Ninja Tile it should create.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDescription
    map + + +Phaser.Tilemap + + + + + + + + + +

    The Tilemap to get the map data from.

    layer + + +number +| + +string +| + +Phaser.TilemapLayer + + + + + + <optional>
    + + + + + +

    The layer to operate on. If not given will default to map.currentLayer.

    slopeMap + + +object + + + + + + <optional>
    + + + + + +

    The tilemap index to Tile ID map.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    An array of the Phaser.Physics.Ninja.Tile objects that were created.

    +
    + + + +
    +
    + Type +
    +
    + +array + + +
    +
    + + + + + +
    + + + +
    +

    enable(object, type, id, radius, children)

    + + +
    +
    + + +
    +

    This will create a Ninja Physics body on the given game object or array of game objects. +A game object can only have 1 physics body active at any one time, and it can't be changed until the object is destroyed.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    object + + +object +| + +array +| + +Phaser.Group + + + + + + + + + + + +

    The game object to create the physics body on. Can also be an array or Group of objects, a body will be created on every child that has a body property.

    type + + +number + + + + + + <optional>
    + + + + + +
    + + 1 + +

    The type of Ninja shape to create. 1 = AABB, 2 = Circle or 3 = Tile.

    id + + +number + + + + + + <optional>
    + + + + + +
    + + 1 + +

    If this body is using a Tile shape, you can set the Tile id here, i.e. Phaser.Physics.Ninja.Tile.SLOPE_45DEGpn, Phaser.Physics.Ninja.Tile.CONVEXpp, etc.

    radius + + +number + + + + + + <optional>
    + + + + + +
    + + 0 + +

    If this body is using a Circle shape this controls the radius.

    children + + +boolean + + + + + + <optional>
    + + + + + +
    + + true + +

    Should a body be created on all children of this object? If true it will recurse down the display list as far as it can go.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    enableAABB(object, children)

    + + +
    +
    + + +
    +

    This will create a Ninja Physics AABB body on the given game object. Its dimensions will match the width and height of the object at the point it is created. +A game object can only have 1 physics body active at any one time, and it can't be changed until the object is destroyed.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    object + + +object +| + +array +| + +Phaser.Group + + + + + + + + + + + +

    The game object to create the physics body on. Can also be an array or Group of objects, a body will be created on every child that has a body property.

    children + + +boolean + + + + + + <optional>
    + + + + + +
    + + true + +

    Should a body be created on all children of this object? If true it will recurse down the display list as far as it can go.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    enableBody(object)

    + + +
    +
    + + +
    +

    Creates a Ninja Physics body on the given game object. +A game object can only have 1 physics body active at any one time, and it can't be changed until the body is nulled.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    object + + +object + + + +

    The game object to create the physics body on. A body will only be created if this object has a null body property.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    enableCircle(object, radius, children)

    + + +
    +
    + + +
    +

    This will create a Ninja Physics Circle body on the given game object. +A game object can only have 1 physics body active at any one time, and it can't be changed until the object is destroyed.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    object + + +object +| + +array +| + +Phaser.Group + + + + + + + + + + + +

    The game object to create the physics body on. Can also be an array or Group of objects, a body will be created on every child that has a body property.

    radius + + +number + + + + + + + + + + + +

    The radius of the Circle.

    children + + +boolean + + + + + + <optional>
    + + + + + +
    + + true + +

    Should a body be created on all children of this object? If true it will recurse down the display list as far as it can go.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    enableTile(object, id, children)

    + + +
    +
    + + +
    +

    This will create a Ninja Physics Tile body on the given game object. There are 34 different types of tile you can create, including 45 degree slopes, +convex and concave circles and more. The id parameter controls which Tile type is created, but you can also change it at run-time. +Note that for all degree based tile types they need to have an equal width and height. If the given object doesn't have equal width and height it will use the width. +A game object can only have 1 physics body active at any one time, and it can't be changed until the object is destroyed.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    object + + +object +| + +array +| + +Phaser.Group + + + + + + + + + + + +

    The game object to create the physics body on. Can also be an array or Group of objects, a body will be created on every child that has a body property.

    id + + +number + + + + + + <optional>
    + + + + + +
    + + 1 + +

    The type of Tile this will use, i.e. Phaser.Physics.Ninja.Tile.SLOPE_45DEGpn, Phaser.Physics.Ninja.Tile.CONVEXpp, etc.

    children + + +boolean + + + + + + <optional>
    + + + + + +
    + + true + +

    Should a body be created on all children of this object? If true it will recurse down the display list as far as it can go.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    overlap(object1, object2, overlapCallback, processCallback, callbackContext) → {boolean}

    + + +
    +
    + + +
    +

    Checks for overlaps between two game objects. The objects can be Sprites, Groups or Emitters. +You can perform Sprite vs. Sprite, Sprite vs. Group and Group vs. Group overlap checks. +Unlike collide the objects are NOT automatically separated or have any physics applied, they merely test for overlap results. +The second parameter can be an array of objects, of differing types.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    object1 + + +Phaser.Sprite +| + +Phaser.Group +| + +Phaser.Particles.Emitter + + + + + + + + + + + +

    The first object to check. Can be an instance of Phaser.Sprite, Phaser.Group or Phaser.Particles.Emitter.

    object2 + + +Phaser.Sprite +| + +Phaser.Group +| + +Phaser.Particles.Emitter +| + +array + + + + + + + + + + + +

    The second object or array of objects to check. Can be Phaser.Sprite, Phaser.Group or Phaser.Particles.Emitter.

    overlapCallback + + +function + + + + + + <optional>
    + + + + + +
    + + null + +

    An optional callback function that is called if the objects overlap. The two objects will be passed to this function in the same order in which you specified them.

    processCallback + + +function + + + + + + <optional>
    + + + + + +
    + + null + +

    A callback function that lets you perform additional checks against the two objects if they overlap. If this is set then overlapCallback will only be called if processCallback returns true.

    callbackContext + + +object + + + + + + <optional>
    + + + + + +
    + +

    The context in which to run the callbacks.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    True if an overlap occured otherwise false.

    +
    + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    separate(body1, body2, processCallback, callbackContext) → {boolean}

    + + +
    +
    + + +
    +

    The core separation function to separate two physics bodies.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    body1 + + +Phaser.Physics.Ninja.Body + + + + + + + + + + + +

    The Body object to separate.

    body2 + + +Phaser.Physics.Ninja.Body + + + + + + + + + + + +

    The Body object to separate.

    processCallback + + +function + + + + + + <optional>
    + + + + + +
    + + null + +

    UN-USED: A callback function that lets you perform additional checks against the two objects if they overlap. If this function is set then the sprites will only be collided if it returns true.

    callbackContext + + +object + + + + + + <optional>
    + + + + + +
    + +

    UN-USED: The context in which to run the process callback.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    Returns true if the bodies collided, otherwise false.

    +
    + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    setBounds(x, y, width, height)

    + + +
    +
    + + +
    +

    Updates the size of this physics world.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    x + + +number + + + +

    Top left most corner of the world.

    y + + +number + + + +

    Top left most corner of the world.

    width + + +number + + + +

    New width of the world. Can never be smaller than the Game.width.

    height + + +number + + + +

    New height of the world. Can never be smaller than the Game.height.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    setBoundsToWorld()

    + + +
    +
    + + +
    +

    Updates the size of this physics world to match the size of the game world.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2014 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Mar 14 2014 06:34:28 GMT-0000 (GMT) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.Physics.Body.html b/docs/Phaser.Physics.P2.Body.html similarity index 87% rename from docs/Phaser.Physics.Body.html rename to docs/Phaser.Physics.P2.Body.html index 99830afef4..c49a396a50 100644 --- a/docs/Phaser.Physics.Body.html +++ b/docs/Phaser.Physics.P2.Body.html @@ -58,10 +58,6 @@ BitmapData -
  • - BitmapFont -
  • -
  • BitmapText
  • @@ -259,35 +255,83 @@
  • - Body + Body +
  • + +
  • + Ninja +
  • + +
  • + AABB +
  • + +
  • + Body +
  • + +
  • + Circle +
  • + +
  • + Tile +
  • + +
  • + P2 +
  • + +
  • + Body +
  • + +
  • + BodyDebug +
  • + +
  • + CollisionGroup +
  • + +
  • + ContactMaterial +
  • + +
  • + DistanceConstraint
  • - CollisionGroup + GearConstraint
  • - ContactMaterial + InversePointProxy
  • - InversePointProxy + LockConstraint
  • - Material + Material
  • - PointProxy + PointProxy
  • - Spring + PrismaticConstraint
  • - World + RevoluteConstraint +
  • + +
  • + Spring
  • @@ -310,6 +354,10 @@ Polygon
  • +
  • + QuadTree +
  • +
  • RandomDataGenerator
  • @@ -326,6 +374,14 @@ RequestAnimationFrame +
  • + RetroFont +
  • + +
  • + ScaleManager +
  • +
  • Signal
  • @@ -354,10 +410,6 @@ Stage -
  • - StageScaleMode -
  • -
  • State
  • @@ -438,40 +490,6 @@ - - @@ -490,7 +508,7 @@

    Class: Body

    - Phaser.Physics. + Phaser.Physics.P2. Body

    @@ -517,7 +535,8 @@

    new BodyThe Physics Body is typically linked to a single Sprite and defines properties that determine how the physics body is simulated. These properties affect how the body reacts to forces, what forces it generates on itself (to simulate friction), and how it reacts to collisions in the scene. In most cases, the properties are used to simulate physical effects. Each body also has its own property values that determine exactly how it reacts to forces and collisions in the scene. -By default a single Rectangle shape is added to the Body that matches the dimensions of the parent Sprite. See addShape, removeShape, clearShapes to add extra shapes around the Body.

    +By default a single Rectangle shape is added to the Body that matches the dimensions of the parent Sprite. See addShape, removeShape, clearShapes to add extra shapes around the Body. +Note: When bound to a Sprite to avoid single-pixel jitters on mobile devices we strongly recommend using Sprite sizes that are even on both axis, i.e. 128x128 not 127x127.

    @@ -769,7 +788,7 @@
    Parameters:
    Source:
    @@ -897,7 +916,7 @@
    Properties:
    Source:
    @@ -1005,7 +1024,7 @@
    Properties:
    Source:
    @@ -1111,7 +1130,7 @@
    Properties:
    Source:
    @@ -1213,7 +1232,7 @@
    Properties:
    Source:
    @@ -1315,7 +1334,7 @@
    Properties:
    Source:
    @@ -1422,7 +1441,7 @@
    Properties:
    Source:
    @@ -1528,7 +1547,7 @@
    Properties:
    Source:
    @@ -1591,7 +1610,7 @@
    Properties:
    -p2.Body +p2.Body @@ -1630,7 +1649,7 @@
    Properties:
    Source:
    @@ -1648,7 +1667,7 @@
    Properties:
    -

    dynamic

    +

    debug

    @@ -1687,7 +1706,7 @@
    Properties:
    - dynamic + debug @@ -1703,7 +1722,7 @@
    Properties:
    -

    Returns true if the Body is dynamic. Setting Body.dynamic to 'false' will make it static.

    +

    Enable or disable debug drawing of this body

    @@ -1732,7 +1751,7 @@
    Properties:
    Source:
    @@ -1750,7 +1769,7 @@
    Properties:
    -

    fixedRotation

    +

    debugBody

    @@ -1789,13 +1808,13 @@
    Properties:
    - fixedRotation + debugBody -boolean +Phaser.Physics.P2.BodyDebug @@ -1805,7 +1824,7 @@
    Properties:
    -

    -

    +

    Reference to the debug body.

    @@ -1834,7 +1853,7 @@
    Properties:
    Source:
    @@ -1852,7 +1871,7 @@
    Properties:
    -

    force

    +

    dynamic

    @@ -1891,13 +1910,13 @@
    Properties:
    - force + dynamic -Phaser.InversePointProxy +boolean @@ -1907,7 +1926,7 @@
    Properties:
    -

    The force applied to the body.

    +

    Returns true if the Body is dynamic. Setting Body.dynamic to 'false' will make it static.

    @@ -1936,7 +1955,7 @@
    Properties:
    Source:
    @@ -1954,7 +1973,7 @@
    Properties:
    -

    game

    +

    fixedRotation

    @@ -1993,13 +2012,13 @@
    Properties:
    - game + fixedRotation -Phaser.Game +boolean @@ -2009,7 +2028,7 @@
    Properties:
    -

    Local reference to game.

    +

    -

    @@ -2038,7 +2057,7 @@
    Properties:
    Source:
    @@ -2056,7 +2075,7 @@
    Properties:
    -

    gravity

    +

    force

    @@ -2095,13 +2114,13 @@
    Properties:
    - gravity + force -Phaser.Point +Phaser.InversePointProxy @@ -2111,7 +2130,7 @@
    Properties:
    -

    A locally applied gravity force to the Body. Applied directly before the world step. NOTE: Not currently implemented.

    +

    The force applied to the body.

    @@ -2140,7 +2159,7 @@
    Properties:
    Source:
    @@ -2158,7 +2177,7 @@
    Properties:
    -

    inertia

    +

    game

    @@ -2197,13 +2216,13 @@
    Properties:
    - inertia + game -number +Phaser.Game @@ -2213,7 +2232,7 @@
    Properties:
    -

    The inertia of the body around the Z axis..

    +

    Local reference to game.

    @@ -2242,7 +2261,7 @@
    Properties:
    Source:
    @@ -2260,7 +2279,7 @@
    Properties:
    -

    kinematic

    +

    gravity

    @@ -2299,13 +2318,13 @@
    Properties:
    - kinematic + gravity -boolean +Phaser.Point @@ -2315,7 +2334,7 @@
    Properties:
    -

    Returns true if the Body is kinematic. Setting Body.kinematic to 'false' will make it static.

    +

    A locally applied gravity force to the Body. Applied directly before the world step. NOTE: Not currently implemented.

    @@ -2344,7 +2363,7 @@
    Properties:
    Source:
    @@ -2362,7 +2381,7 @@
    Properties:
    -

    mass

    +

    <readonly> id

    @@ -2401,7 +2420,7 @@
    Properties:
    - mass + id @@ -2417,7 +2436,7 @@
    Properties:
    -

    -

    +

    The Body ID. Each Body that has been added to the World has a unique ID.

    @@ -2446,7 +2465,7 @@
    Properties:
    Source:
    @@ -2464,7 +2483,7 @@
    Properties:
    -

    motionState

    +

    inertia

    @@ -2503,7 +2522,7 @@
    Properties:
    - motionState + inertia @@ -2519,7 +2538,7 @@
    Properties:
    -

    The type of motion this body has. Should be one of: Body.STATIC (the body does not move), Body.DYNAMIC (body can move and respond to collisions) and Body.KINEMATIC (only moves according to its .velocity).

    +

    The inertia of the body around the Z axis..

    @@ -2548,7 +2567,7 @@
    Properties:
    Source:
    @@ -2566,7 +2585,7 @@
    Properties:
    -

    offset

    +

    kinematic

    @@ -2605,13 +2624,13 @@
    Properties:
    - offset + kinematic -Phaser.Point +boolean @@ -2621,7 +2640,7 @@
    Properties:
    -

    The offset of the Physics Body from the Sprite x/y position.

    +

    Returns true if the Body is kinematic. Setting Body.kinematic to 'false' will make it static.

    @@ -2650,7 +2669,7 @@
    Properties:
    Source:
    @@ -2668,7 +2687,7 @@
    Properties:
    -

    onImpact

    +

    mass

    @@ -2707,13 +2726,13 @@
    Properties:
    - onImpact + mass -Phaser.Signal +number @@ -2723,7 +2742,7 @@
    Properties:
    -

    Dispatched when the shape/s of this Body impact with another. The event will be sent 2 parameters, this Body and the impact Body.

    +

    -

    @@ -2752,7 +2771,7 @@
    Properties:
    Source:
    @@ -2770,17 +2789,12 @@
    Properties:
    -

    rotation

    +

    motionState

    -
    -

    The angle of the Body in radians. -If you wish to work in degrees instead of radians use the Body.angle property instead. Working in radians is faster as it doesn't have to convert values.

    -
    - @@ -2814,7 +2828,7 @@
    Properties:
    - rotation + motionState @@ -2830,7 +2844,7 @@
    Properties:
    -

    The angle of this Body in radians.

    +

    The type of motion this body has. Should be one of: Body.STATIC (the body does not move), Body.DYNAMIC (body can move and respond to collisions) and Body.KINEMATIC (only moves according to its .velocity).

    @@ -2859,7 +2873,7 @@
    Properties:
    Source:
    @@ -2877,7 +2891,7 @@
    Properties:
    -

    sleepSpeedLimit

    +

    offset

    @@ -2916,13 +2930,13 @@
    Properties:
    - sleepSpeedLimit + offset -number +Phaser.Point @@ -2932,7 +2946,7 @@
    Properties:
    -

    .

    +

    The offset of the Physics Body from the Sprite x/y position.

    @@ -2961,7 +2975,7 @@
    Properties:
    Source:
    @@ -2979,12 +2993,17 @@
    Properties:
    -

    sprite

    +

    onBeginContact

    +
    +

    Dispatched when a first contact is created between shapes in two bodies. This event is fired during the step, so collision has already taken place. +The event will be sent 4 parameters: The body it is in contact with, the shape from this body that caused the contact, the shape from the contact body and the contact equation data array.

    +
    + @@ -3018,13 +3037,13 @@
    Properties:
    - sprite + onBeginContact -Phaser.Sprite +Phaser.Signal @@ -3034,7 +3053,7 @@
    Properties:
    -

    Reference to the parent Sprite.

    + @@ -3063,7 +3082,7 @@
    Properties:
    Source:
    @@ -3081,12 +3100,17 @@
    Properties:
    -

    static

    +

    onEndContact

    +
    +

    Dispatched when contact ends between shapes in two bodies. This event is fired during the step, so collision has already taken place. +The event will be sent 3 parameters: The body it is in contact with, the shape from this body that caused the contact and the shape from the contact body.

    +
    + @@ -3120,13 +3144,13 @@
    Properties:
    - static + onEndContact -boolean +Phaser.Signal @@ -3136,7 +3160,7 @@
    Properties:
    -

    Returns true if the Body is static. Setting Body.static to 'false' will make it dynamic.

    + @@ -3165,7 +3189,7 @@
    Properties:
    Source:
    @@ -3183,12 +3207,16 @@
    Properties:
    -

    velocity

    +

    onImpact

    +
    +

    Dispatched when the shape/s of this Body impact with another. The event will be sent 2 parameters, this Body and the impact Body.

    +
    + @@ -3222,13 +3250,13 @@
    Properties:
    - velocity + onImpact -Phaser.InversePointProxy +Phaser.Signal @@ -3238,7 +3266,7 @@
    Properties:
    -

    The velocity of the body. Set velocity.x to a negative value to move to the left, position to the right. velocity.y negative values move up, positive move down.

    + @@ -3267,7 +3295,7 @@
    Properties:
    Source:
    @@ -3285,7 +3313,7 @@
    Properties:
    -

    x

    +

    removeNextStep

    @@ -3324,13 +3352,13 @@
    Properties:
    - x + removeNextStep -number +boolean @@ -3340,7 +3368,7 @@
    Properties:
    -

    The x coordinate of this Body.

    +

    To avoid deleting this body during a physics step, and causing all kinds of problems, set removeNextStep to true to have it removed in the next preUpdate.

    @@ -3369,7 +3397,7 @@
    Properties:
    Source:
    @@ -3387,12 +3415,17 @@
    Properties:
    -

    y

    +

    rotation

    +
    +

    The angle of the Body in radians. +If you wish to work in degrees instead of radians use the Body.angle property instead. Working in radians is faster as it doesn't have to convert values.

    +
    + @@ -3426,7 +3459,7 @@
    Properties:
    - y + rotation @@ -3442,7 +3475,7 @@
    Properties:
    -

    The y coordinate of this Body.

    +

    The angle of this Body in radians.

    @@ -3471,7 +3504,7 @@
    Properties:
    Source:
    @@ -3486,37 +3519,27 @@
    Properties:
    - - - - -

    Methods

    - -
    +
    -

    addCapsule(length, radius, offsetX, offsetY, rotation) → {p2.Capsule}

    +

    sleepSpeedLimit

    -
    -

    Adds a Capsule shape to this Body. -You can control the offset from the center of the body and the rotation.

    -
    +
    - - - -
    Parameters:
    - - +
    Properties:
    + +
    + +
    @@ -3526,12 +3549,8 @@
    Parameters:
    - - - - @@ -3542,7 +3561,7 @@
    Parameters:
    - + - - - - - + + +
    TypeArgumentDefaultDescription
    lengthsleepSpeedLimit @@ -3555,103 +3574,300 @@
    Parameters:
    - - - - - - - -

    The distance between the end points in pixels.

    .

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + +
    +

    sprite

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + - + - + + + + + +
    NameTypeDescription
    radiussprite -number +Phaser.Sprite - - - - -

    Reference to the parent Sprite.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + - - - - +
    +

    static

    + + +
    +
    + + + -

    Radius of the capsule in radians.

    - + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + - + - + + + + + +
    NameTypeDescription
    offsetXstatic -number +boolean - - <optional>
    - - - - -

    Returns true if the Body is static. Setting Body.static to 'false' will make it dynamic.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + - - - 0 - - - +
    +

    type

    + + +
    +
    + + + -

    Local horizontal offset of the shape relative to the body center of mass.

    - + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + - + - + + + + + +
    NameTypeDescription
    offsetYtype @@ -3664,76 +3880,222 @@
    Parameters:
    - - <optional>
    - - - - -

    The type of physics system this body belongs to.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + - - - 0 - - - +
    +

    velocity

    + + +
    +
    + + + -

    Local vertical offset of the shape relative to the body center of mass.

    - + +
    + + +
    Properties:
    +
    + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + +
    NameTypeDescription
    rotationvelocity -number +Phaser.InversePointProxy + + + +

    The velocity of the body. Set velocity.x to a negative value to move to the left, position to the right. velocity.y negative values move up, positive move down.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + +
    + + + +
    + + + +
    +

    world

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + - + + - + - +
    NameTypeDescription
    world - - - <optional>
    +Phaser.Physics.P2 - - -
    - - 0 - -

    Local rotation of the shape relative to the body center of mass, specified in radians.

    Local reference to the P2 World.

    +
    - - -
    - @@ -3754,7 +4116,7 @@
    Parameters:
    Source:
    @@ -3767,65 +4129,29 @@
    Parameters:
    - - - - - - - - -
    Returns:
    - - -
    -

    The Capsule shape that was added to the Body.

    -
    - - - -
    -
    - Type -
    -
    - -p2.Capsule - - -
    -
    - - - - -
    -

    addCircle(radius, offsetX, offsetY, rotation) → {p2.Circle}

    +

    x

    -
    -

    Adds a Circle shape to this Body. You can control the offset from the center of the body and the rotation.

    -
    +
    - - - -
    Parameters:
    - - +
    Properties:
    + +
    + +
    @@ -3835,12 +4161,8 @@
    Parameters:
    - - - - @@ -3851,7 +4173,7 @@
    Parameters:
    - + - - - - - + + +
    TypeArgumentDefaultDescription
    radiusx @@ -3864,107 +4186,96 @@
    Parameters:
    - - - - - - - -

    The radius of this circle (in pixels)

    The x coordinate of this Body.

    +
    - - - offsetX - + - - - -number + + - - + - - - - <optional>
    - + - + - - - + - - - - 0 - - - + -

    Local horizontal offset of the shape relative to the body center of mass.

    - + - + +
    Source:
    +
    + - - - offsetY - + - - - -number + + + - - + + + + - - - <optional>
    - +
    +

    y

    + + +
    +
    + + + - + +
    + - - - +
    Properties:
    - - - - 0 - - - +
    -

    Local vertical offset of the shape relative to the body center of mass.

    - + + + + + + + + + + + + + + + + + - + - - - - - +
    NameTypeDescription
    rotationy @@ -3977,37 +4288,18 @@
    Parameters:
    - - <optional>
    - - - - - -
    - - 0 - -

    Local rotation of the shape relative to the body center of mass, specified in radians.

    The y coordinate of this Body.

    +
    - - -
    - @@ -4028,58 +4320,31 @@
    Parameters:
    Source:
    - - - - - - - -
    - - - - - - - - - - - -
    Returns:
    - - -
    -

    The Circle shape that was added to the Body.

    -
    - - + -
    -
    - Type -
    -
    - -p2.Circle + + -
    +
    - -
    - + + + + +

    Methods

    + +
    -

    addLine(length, offsetX, offsetY, rotation) → {p2.Line}

    +

    addCapsule(length, radius, offsetX, offsetY, rotation) → {p2.Capsule}

    @@ -4087,8 +4352,7 @@

    addLine -

    Adds a Line shape to this Body. -The line shape is along the x direction, and stretches from [-length/2, 0] to [length/2,0]. +

    Adds a Capsule shape to this Body. You can control the offset from the center of the body and the rotation.

    @@ -4155,7 +4419,42 @@
    Parameters:
    -

    The length of this line (in pixels)

    +

    The distance between the end points in pixels.

    + + + + + + + radius + + + + + +number + + + + + + + + + + + + + + + + + + + + + +

    Radius of the capsule in radians.

    @@ -4304,7 +4603,7 @@
    Parameters:
    Source:
    @@ -4329,7 +4628,7 @@
    Returns:
    -

    The Line shape that was added to the Body.

    +

    The Capsule shape that was added to the Body.

    @@ -4340,7 +4639,7 @@
    Returns:
    -p2.Line +p2.Capsule
    @@ -4355,7 +4654,7 @@
    Returns:
    -

    addParticle(offsetX, offsetY, rotation) → {p2.Particle}

    +

    addCircle(radius, offsetX, offsetY, rotation) → {p2.Circle}

    @@ -4363,7 +4662,7 @@

    addParticl
    -

    Adds a Particle shape to this Body. You can control the offset from the center of the body and the rotation.

    +

    Adds a Circle shape to this Body. You can control the offset from the center of the body and the rotation.

    @@ -4399,6 +4698,41 @@

    Parameters:
    + + + radius + + + + + +number + + + + + + + + + + + + + + + + + + + + + +

    The radius of this circle (in pixels)

    + + + + offsetX @@ -4543,7 +4877,7 @@
    Parameters:
    Source:
    @@ -4568,7 +4902,7 @@
    Returns:
    -

    The Particle shape that was added to the Body.

    +

    The Circle shape that was added to the Body.

    @@ -4579,7 +4913,7 @@
    Returns:
    -p2.Particle +p2.Circle
    @@ -4594,7 +4928,7 @@
    Returns:
    -

    addPlane(offsetX, offsetY, rotation) → {p2.Plane}

    +

    addLine(length, offsetX, offsetY, rotation) → {p2.Line}

    @@ -4602,7 +4936,9 @@

    addPlane -

    Adds a Plane shape to this Body. The plane is facing in the Y direction. You can control the offset from the center of the body and the rotation.

    +

    Adds a Line shape to this Body. +The line shape is along the x direction, and stretches from [-length/2, 0] to [length/2,0]. +You can control the offset from the center of the body and the rotation.

    @@ -4638,6 +4974,41 @@
    Parameters:
    + + + length + + + + + +number + + + + + + + + + + + + + + + + + + + + + +

    The length of this line (in pixels)

    + + + + offsetX @@ -4782,7 +5153,7 @@
    Parameters:
    Source:
    @@ -4807,7 +5178,7 @@
    Returns:
    -

    The Plane shape that was added to the Body.

    +

    The Line shape that was added to the Body.

    @@ -4818,7 +5189,7 @@
    Returns:
    -p2.Plane +p2.Line
    @@ -4833,7 +5204,7 @@
    Returns:
    -

    addPolygon(options, points) → {boolean}

    +

    addParticle(offsetX, offsetY, rotation) → {p2.Particle}

    @@ -4841,8 +5212,7 @@

    addPolygon<
    -

    Reads a polygon shape path, and assembles convex shapes from that and puts them at proper offset points. The shape must be simple and without holes. -This function expects the x.y values to be given in pixels. If you want to provide them at p2 world scales then call Body.data.fromPolygon directly.

    +

    Adds a Particle shape to this Body. You can control the offset from the center of the body and the rotation.

    @@ -4864,48 +5234,6 @@

    Parameters:
    Type - - - - Description - - - - - - - - - options - - - - - -object - - - - - - - - - -

    An object containing the build options:

    -
    Properties
    - - - - - - - - - - - - @@ -4922,52 +5250,13 @@
    Properties
    - - - - - - - - - - - - - - - - - - - - - + - + - + - - - - - -
    NameTypeArgument
    optimalDecomp - - -boolean - - - - - - <optional>
    - - - - - -
    - - false - -

    Set to true if you need optimal decomposition. Warning: very slow for polygons with more than 10 vertices.

    skipSimpleCheckoffsetX -boolean +number @@ -4988,27 +5277,24 @@
    Properties
    - false + 0

    Set to true if you already know that the path is not intersecting itself.

    Local horizontal offset of the shape relative to the body center of mass.

    removeCollinearPointsoffsetY - -boolean -| - + number @@ -5030,34 +5316,24 @@
    Properties
    - false + 0

    Set to a number (angle threshold value) to remove collinear points, or false to keep all points.

    - - +

    Local vertical offset of the shape relative to the body center of mass.

    - points + rotation -Array.<number> -| - number @@ -5065,12 +5341,26 @@
    Properties
    + + + <optional>
    + + + + + -

    An array of 2d vectors that form the convex or concave polygon. - Either [[0,0], [0,1],...] or a flat array of numbers that will be interpreted as [x,y, x,y, ...], - or the arguments passed can be flat x,y values e.g. setPolygon(options, x,y, x,y, x,y, ...) where x and y are numbers.

    + + + + 0 + + + + +

    Local rotation of the shape relative to the body center of mass, specified in radians.

    @@ -5102,7 +5392,7 @@
    Properties
    Source:
    @@ -5127,7 +5417,7 @@
    Returns:
    -

    True on success, else false.

    +

    The Particle shape that was added to the Body.

    @@ -5138,7 +5428,7 @@
    Returns:
    -boolean +p2.Particle
    @@ -5153,7 +5443,7 @@
    Returns:
    -

    addRectangle(width, height, offsetX, offsetY, rotation) → {p2.Rectangle}

    +

    addPlane(offsetX, offsetY, rotation) → {p2.Plane}

    @@ -5161,7 +5451,7 @@

    addRectan
    -

    Adds a Rectangle shape to this Body. You can control the offset from the center of the body and the rotation.

    +

    Adds a Plane shape to this Body. The plane is facing in the Y direction. You can control the offset from the center of the body and the rotation.

    @@ -5197,76 +5487,6 @@

    Parameters:
    - - - width - - - - - -number - - - - - - - - - - - - - - - - - - - - - -

    The width of the rectangle in pixels.

    - - - - - - - height - - - - - -number - - - - - - - - - - - - - - - - - - - - - -

    The height of the rectangle in pixels.

    - - - - offsetX @@ -5411,7 +5631,7 @@
    Parameters:
    Source:
    @@ -5436,7 +5656,7 @@
    Returns:
    -

    The Rectangle shape that was added to the Body.

    +

    The Plane shape that was added to the Body.

    @@ -5447,7 +5667,7 @@
    Returns:
    -p2.Rectangle +p2.Plane
    @@ -5462,7 +5682,7 @@
    Returns:
    -

    addShape(shape, offsetX, offsetY, rotation) → {p2.Circle|p2.Rectangle|p2.Plane|p2.Line|p2.Particle}

    +

    addPolygon(options, points) → {boolean}

    @@ -5470,8 +5690,8 @@

    addShape -

    Add a shape to the body. You can pass a local transform when adding a shape, so that the shape gets an offset and an angle relative to the body center of mass. -Will automatically update the mass properties and bounding radius.

    +

    Reads a polygon shape path, and assembles convex shapes from that and puts them at proper offset points. The shape must be simple and without holes. +This function expects the x.y values to be given in pixels. If you want to provide them at p2 world scales then call Body.data.fromPolygon directly.

    @@ -5493,12 +5713,8 @@
    Parameters:
    Type - Argument - - Default - Description @@ -5509,48 +5725,59 @@
    Parameters:
    - shape + options -* +object - - - - - - - - +

    An object containing the build options:

    +
    Properties
    - - -

    The shape to add to the body.

    - + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + - +
    NameTypeArgumentDefaultDescription
    offsetXoptimalDecomp -number +boolean @@ -5571,25 +5798,25 @@
    Parameters:
    - 0 + false

    Local horizontal offset of the shape relative to the body center of mass.

    Set to true if you need optimal decomposition. Warning: very slow for polygons with more than 10 vertices.

    offsetYskipSimpleCheck -number +boolean @@ -5610,24 +5837,27 @@
    Parameters:
    - 0 + false

    Local vertical offset of the shape relative to the body center of mass.

    Set to true if you already know that the path is not intersecting itself.

    rotationremoveCollinearPoints +boolean +| + number @@ -5649,122 +5879,53 @@
    Parameters:
    - 0 + false

    Local rotation of the shape relative to the body center of mass, specified in radians.

    Set to a number (angle threshold value) to remove collinear points, or false to keep all points.

    - - - -
    - - - - - - - - - - - - - - - - - - - -
    Source:
    -
    - - - - - - - -
    - - - - - - - - - - - -
    Returns:
    - - -
    -

    The shape that was added to the body.

    -
    - - - -
    -
    - Type -
    -
    - -p2.Circle -| - -p2.Rectangle -| + + -p2.Plane -| + -p2.Line -| + + + points + -p2.Particle + + + +Array.<number> +| +number -
    -
    + + - - - - + - -
    -

    addToWorld()

    - - -
    -
    - - -
    -

    Adds this physics body to the world.

    -
    - - - - - +

    An array of 2d vectors that form the convex or concave polygon. + Either [[0,0], [0,1],...] or a flat array of numbers that will be interpreted as [x,y, x,y, ...], + or the arguments passed can be flat x,y values e.g. setPolygon(options, x,y, x,y, x,y, ...) where x and y are numbers.

    + + + + + + @@ -5790,7 +5951,7 @@

    addToWorld<
    Source:
    @@ -5811,75 +5972,29 @@

    addToWorld< +

    Returns:
    - -
    - - -
    -

    adjustCenterOfMass()

    - - -
    -
    - - -
    -

    Moves the shape offsets so their center of mass becomes the body center of mass.

    -
    - - - - - - - - - -
    - - - - - - - - - - - - - - - +
    +

    True on success, else false.

    +
    - - -
    Source:
    -
    - - +
    +
    + Type +
    +
    + +boolean - - +
    - - - - - - - - - +
    @@ -5887,7 +6002,7 @@

    adj
    -

    applyDamping(dt)

    +

    addRectangle(width, height, offsetX, offsetY, rotation) → {p2.Rectangle}

    @@ -5895,7 +6010,7 @@

    applyDamp
    -

    Apply damping, see http://code.google.com/p/bullet/issues/detail?id=74 for details.

    +

    Adds a Rectangle shape to this Body. You can control the offset from the center of the body and the rotation.

    @@ -5917,8 +6032,12 @@

    Parameters:
    Type + Argument + + Default + Description @@ -5929,7 +6048,7 @@
    Parameters:
    - dt + width @@ -5942,112 +6061,64 @@
    Parameters:
    + + + + + + -

    Current time step.

    + + + + + + +

    The width of the rectangle in pixels.

    - - - - - - -
    - - - - - - - - - - - - - - - - - - -
    Source:
    -
    - - - - - - - -
    - - - + + + height + - + + + +number - - - - - - - - - -
    -

    applyForce(force, worldX, worldY)

    - - -
    -
    - - -
    -

    Apply force to a world point. This could for example be a point on the RigidBody surface. Applying force this way will add to Body.force and Body.angularForce.

    -
    - - - - - - - -
    Parameters:
    - + - - - - - - + + + - + + + - + + + - - - + + - - + + - + + + + + - + + - + + + + + - + + + + + - + @@ -6141,7 +6260,7 @@
    Parameters:
    Source:
    @@ -6162,6 +6281,29 @@
    Parameters:
    +
    Returns:
    + + +
    +

    The Rectangle shape that was added to the Body.

    +
    + + + +
    +
    + Type +
    +
    + +p2.Rectangle + + +
    +
    + + + @@ -6169,7 +6311,7 @@
    Parameters:
    -

    clearCollision(clearGroup, clearMask, shape)

    +

    addShape(shape, offsetX, offsetY, rotation) → {p2.Circle|p2.Rectangle|p2.Plane|p2.Line|p2.Particle}

    @@ -6177,7 +6319,8 @@

    clearCo
    -

    Clears the collision data from the shapes in this Body. Optionally clears Group and/or Mask.

    +

    Add a shape to the body. You can pass a local transform when adding a shape, so that the shape gets an offset and an angle relative to the body center of mass. +Will automatically update the mass properties and bounding radius.

    @@ -6215,13 +6358,48 @@

    Parameters:
    - + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + @@ -6355,7 +6535,7 @@
    Parameters:
    Source:
    @@ -6376,6 +6556,41 @@
    Parameters:
    +
    Returns:
    + + +
    +

    The shape that was added to the body.

    +
    + + + +
    +
    + Type +
    +
    + +p2.Circle +| + +p2.Rectangle +| + +p2.Plane +| + +p2.Line +| + +p2.Particle + + +
    +
    + + + @@ -6383,7 +6598,7 @@
    Parameters:
    -

    clearShapes()

    +

    addToWorld()

    @@ -6391,7 +6606,7 @@

    clearShape
    -

    Removes all Shapes from this Body.

    +

    Adds this physics body to the world.

    @@ -6424,7 +6639,7 @@

    clearShape
    Source:
    @@ -6452,7 +6667,7 @@

    clearShape
    -

    collides(group, callback, callbackContext, shape)

    +

    adjustCenterOfMass()

    @@ -6460,7 +6675,76 @@

    collides -

    Adds the given CollisionGroup, or array of CollisionGroups, to the list of groups that this body will collide with and updates the collision masks.

    +

    Moves the shape offsets so their center of mass becomes the body center of mass.

    + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + + + + + +
    +

    applyDamping(dt)

    + + +
    +
    + + +
    +

    Apply damping, see http://code.google.com/p/bullet/issues/detail?id=74 for details.

    @@ -6482,8 +6766,6 @@
    Parameters:

    - - @@ -6496,133 +6778,23 @@
    Parameters:
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - + @@ -6654,7 +6826,7 @@
    Parameters:
    Source:
    @@ -6682,7 +6854,7 @@
    Parameters:
    -

    createBodyCallback(body, callback, callbackContext)

    +

    applyForce(force, worldX, worldY)

    @@ -6690,8 +6862,7 @@

    cre
    -

    Sets a callback to be fired any time this Body impacts with the given Body. The impact test is performed against body.id values. -The callback will be sent 4 parameters: This body, the body that impacted, the Shape in this body and the shape in the impacting body.

    +

    Apply force to a world point. This could for example be a point on the RigidBody surface. Applying force this way will add to Body.force and Body.angularForce.

    @@ -6725,13 +6896,13 @@

    Parameters:
    - + + - + + - + + @@ -6819,7 +6990,7 @@
    Parameters:
    Source:
    @@ -6847,7 +7018,7 @@
    Parameters:
    -

    createGroupCallback(group, callback, callbackContext)

    +

    clearCollision(clearGroup, clearMask, shape)

    @@ -6855,9 +7026,7 @@

    cr
    -

    Sets a callback to be fired any time this Body impacts with the given Group. The impact test is performed against shape.collisionGroup values. -The callback will be sent 4 parameters: This body, the body that impacted, the Shape in this body and the shape in the impacting body. -This callback will only fire if this Body has been assigned a collision group.

    +

    Clears the collision data from the shapes in this Body. Optionally clears Group and/or Mask.

    @@ -6879,8 +7048,12 @@

    Parameters:
    + + + + @@ -6891,144 +7064,121 @@
    Parameters:
    - + + - + + + + + - + + + + + - + - + + - - - - -
    Name + - Type + + Description

    The height of the rectangle in pixels.

    forceoffsetX @@ -6060,17 +6131,33 @@
    Parameters:
    + + <optional>
    + + + + +

    The force to add.

    + + 0 + +

    Local horizontal offset of the shape relative to the body center of mass.

    worldXoffsetY @@ -6083,17 +6170,33 @@
    Parameters:
    + + <optional>
    + + + + +

    The world x point to apply the force on.

    + + 0 + +

    Local vertical offset of the shape relative to the body center of mass.

    worldYrotation @@ -6106,10 +6209,26 @@
    Parameters:
    + + <optional>
    + + + + + +
    + + 0 + +

    The world y point to apply the force on.

    Local rotation of the shape relative to the body center of mass, specified in radians.

    clearGroupshape -boolean +* + + + + + + + + + + + +

    The shape to add to the body.

    offsetX + + +number @@ -6242,25 +6420,25 @@
    Parameters:
    - true + 0

    Clear the collisionGroup value from the shape/s?

    Local horizontal offset of the shape relative to the body center of mass.

    clearMaskoffsetY -boolean +number @@ -6281,25 +6459,25 @@
    Parameters:
    - true + 0

    Clear the collisionMask value from the shape/s?

    Local vertical offset of the shape relative to the body center of mass.

    shaperotation -p2.Shape +number @@ -6320,10 +6498,12 @@
    Parameters:
    + 0 +

    An optional Shape. If not provided the collision data will be cleared from all Shapes in this Body.

    Local rotation of the shape relative to the body center of mass, specified in radians.

    TypeArgument
    group - - -Phaser.Physics.CollisionGroup -| - -array - - - - - - - - - -

    The Collision Group or Array of Collision Groups that this Bodies shapes will collide with.

    callback - - -function - - - - - - <optional>
    - - - - - -

    Optional callback that will be triggered when this Body impacts with the given Group.

    callbackContext - - -object - - - - - - <optional>
    - - - - - -

    The context under which the callback will be called.

    shapedt -p2.Shape +number - - <optional>
    - - - - - -

    An optional Shape. If not provided the collision mask will be added to all Shapes in this Body.

    Current time step.

    bodyforce -Phaser.Physics.Body +number @@ -6741,20 +6912,20 @@
    Parameters:
    -

    The Body to send impact events for.

    The force to add.

    callbackworldX -function +number @@ -6764,20 +6935,20 @@
    Parameters:
    -

    The callback to fire on impact. Set to null to clear a previously set callback.

    The world x point to apply the force on.

    callbackContextworldY -object +number @@ -6787,7 +6958,7 @@
    Parameters:
    -

    The context under which the callback will fire.

    The world y point to apply the force on.

    TypeArgumentDefaultDescription
    groupclearGroup -Phaser.Physics.CollisionGroup +boolean + + <optional>
    + + + + +

    The Group to send impact events for.

    + + true + +

    Clear the collisionGroup value from the shape/s?

    callbackclearMask -function +boolean + + <optional>
    + + + + + +
    + + true + +

    The callback to fire on impact. Set to null to clear a previously set callback.

    Clear the collisionMask value from the shape/s?

    callbackContextshape -object +p2.Shape + + <optional>
    + - - -

    The context under which the callback will fire.

    - - - - -
    - - - - - - - - - - - - - - - - - - - -
    Source:
    -
    - - - - - - - -
    - - - - - + - - - - - - - -
    + + + - -
    -

    destroy()

    - - -
    -
    - - -
    -

    Destroys this Body and all references it holds to other objects.

    -
    - + + + + + +

    An optional Shape. If not provided the collision data will be cleared from all Shapes in this Body.

    + + + + + - - - - @@ -7054,7 +7204,7 @@

    destroySource:
    @@ -7082,7 +7232,7 @@

    destroy -

    getCollisionMask() → {number}

    +

    clearShapes()

    @@ -7090,7 +7240,7 @@

    getCo
    -

    Gets the collision bitmask from the groups this body collides with.

    +

    Removes all Shapes from this Body.

    @@ -7123,7 +7273,7 @@

    getCo
    Source:
    @@ -7144,29 +7294,6 @@

    getCo -

    Returns:
    - - -
    -

    The bitmask.

    -
    - - - -
    -
    - Type -
    -
    - -number - - -
    -
    - - -

    @@ -7174,7 +7301,7 @@
    Returns:
    -

    loadPolygon(key, object, options) → {boolean}

    +

    collides(group, callback, callbackContext, shape)

    @@ -7182,7 +7309,7 @@

    loadPolygo
    -

    Reads the shape data from a physics data file stored in the Game.Cache and adds it as a polygon to this Body.

    +

    Adds the given CollisionGroup, or array of CollisionGroups, to the list of groups that this body will collide with and updates the collision masks.

    @@ -7204,6 +7331,8 @@

    Parameters:
    Type + Argument + @@ -7216,53 +7345,74 @@
    Parameters:
    - key + group -string +Phaser.Physics.CollisionGroup +| + +array + + + + + + + + -

    The key of the Physics Data file as stored in Game.Cache.

    +

    The Collision Group or Array of Collision Groups that this Bodies shapes will collide with.

    - object + callback -string +function + + + <optional>
    + + + + + + + -

    The key of the object within the Physics data file that you wish to load the shape data from.

    +

    Optional callback that will be triggered when this Body impacts with the given Group.

    - options + callbackContext @@ -7275,46 +7425,33 @@
    Parameters:
    - - - -

    An object containing the build options:

    -
    Properties
    + + + <optional>
    - - - - - - - - + - - - + + + - - - + - - - + + - - + - - + + +
    NameTypeArgumentDefaultDescription

    The context under which the callback will be called.

    optimalDecompshape -boolean +p2.Shape @@ -7333,102 +7470,184 @@
    Properties
    -
    - - false - -

    Set to true if you need optimal decomposition. Warning: very slow for polygons with more than 10 vertices.

    An optional Shape. If not provided the collision mask will be added to all Shapes in this Body.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + + + + + +
    +

    createBodyCallback(object, callback, callbackContext)

    + + +
    +
    + + +
    +

    Sets a callback to be fired any time a shape in this Body impacts with a shape in the given Body. The impact test is performed against body.id values. +The callback will be sent 4 parameters: This body, the body that impacted, the Shape in this body and the shape in the impacting body. +Note that the impact event happens after collision resolution, so it cannot be used to prevent a collision from happening. +It also happens mid-step. So do not destroy a Body during this callback, instead set safeDestroy to true so it will be killed on the next preUpdate.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + - + +Phaser.TileSprite +| - - - - + + - + + + - + - + + + + + + + + + +object + + + - - + - - -
    NameTypeDescription
    skipSimpleCheckobject -boolean - +Phaser.Sprite +| - - - - <optional>
    - +Phaser.Physics.P2.Body +| - +p2.Body - -
    - - false - -

    Set to true if you already know that the path is not intersecting itself.

    The object to send impact events for.

    removeCollinearPointscallback -boolean -| - -number +function - - <optional>
    - - + - -

    The callback to fire on impact. Set to null to clear a previously set callback.

    callbackContext - - - false -

    Set to a number (angle threshold value) to remove collinear points, or false to keep all points.

    + - +

    The context under which the callback will fire.

    @@ -7460,7 +7679,7 @@
    Properties
    Source:
    @@ -7481,29 +7700,6 @@
    Properties
    -
    Returns:
    - - -
    -

    True on success, else false.

    -
    - - - -
    -
    - Type -
    -
    - -boolean - - -
    -
    - - - @@ -7511,7 +7707,7 @@
    Returns:
    -

    loadPolygon(key, object, options) → {boolean}

    +

    createGroupCallback(group, callback, callbackContext)

    @@ -7519,8 +7715,11 @@

    loadPolygo
    -

    Reads the physics data from a physics data file stored in the Game.Cache. -It will add the shape data to this Body, as well as set the density (mass), friction and bounce (restitution) values.

    +

    Sets a callback to be fired any time this Body impacts with the given Group. The impact test is performed against shape.collisionGroup values. +The callback will be sent 4 parameters: This body, the body that impacted, the Shape in this body and the shape in the impacting body. +This callback will only fire if this Body has been assigned a collision group. +Note that the impact event happens after collision resolution, so it cannot be used to prevent a collision from happening. +It also happens mid-step. So do not destroy a Body during this callback, instead set safeDestroy to true so it will be killed on the next preUpdate.

    @@ -7554,13 +7753,13 @@

    Parameters:
    - key + group -string +Phaser.Physics.CollisionGroup @@ -7570,20 +7769,20 @@
    Parameters:
    -

    The key of the Physics Data file as stored in Game.Cache.

    +

    The Group to send impact events for.

    - object + callback -string +function @@ -7593,14 +7792,14 @@
    Parameters:
    -

    The key of the object within the Physics data file that you wish to load the shape data from.

    +

    The callback to fire on impact. Set to null to clear a previously set callback.

    - options + callbackContext @@ -7616,166 +7815,154 @@
    Parameters:
    -

    An object containing the build options:

    -
    Properties
    - - - - - - - - - - - - - - - - - - - - - - + + - + +
    NameTypeArgumentDefaultDescription

    The context under which the callback will fire.

    - - - optimalDecomp - + + + +
    + - - - -boolean + + - - + - - - - <optional>
    - + - + - - - + - - - - false - - - + -

    Set to true if you need optimal decomposition. Warning: very slow for polygons with more than 10 vertices.

    - + - + +
    Source:
    +
    + - - - skipSimpleCheck - + - - - -boolean + + +
    - - + + - - - - <optional>
    - + - + + + + + + + + - - + +
    +

    destroy()

    + + +
    +
    + + +
    +

    Destroys this Body and all references it holds to other objects.

    +
    + - - - - false - - - + + + + + + + +
    + -

    Set to true if you already know that the path is not intersecting itself.

    - + - + - - - removeCollinearPoints - + - - - -boolean -| + -number + + - - + - - - - <optional>
    - + + + +
    Source:
    +
    + - + - - - + - - - - false - - - + +
    -

    Set to a number (angle threshold value) to remove collinear points, or false to keep all points.

    - + + - - - + - - + + + + + + + +
    - - - + + +
    +

    getCollisionMask() → {number}

    + + +
    +
    + + +
    +

    Gets the collision bitmask from the groups this body collides with.

    +
    + + + + +
    @@ -7798,7 +7985,7 @@
    Properties
    Source:
    @@ -7823,7 +8010,7 @@
    Returns:
    -

    True on success, else false.

    +

    The bitmask.

    @@ -7834,7 +8021,7 @@
    Returns:
    -boolean +number
    @@ -7849,7 +8036,7 @@
    Returns:
    -

    moveBackward(speed)

    +

    loadPolygon(key, object, options) → {boolean}

    @@ -7857,8 +8044,7 @@

    moveBackw
    -

    Moves the Body backwards based on its current angle and the given speed. -The speed is represented in pixels per second. So a value of 100 would move 100 pixels in 1 second (1000ms).

    +

    Reads the shape data from a physics data file stored in the Game.Cache and adds it as a polygon to this Body.

    @@ -7892,13 +8078,13 @@

    Parameters:
    - speed + key -number +string @@ -7908,86 +8094,55 @@
    Parameters:
    -

    The speed at which it should move backwards.

    +

    The key of the Physics Data file as stored in Game.Cache.

    - - - - - - -
    - - - - - - + + + object + - + + + +string - - + + - + - + - -
    Source:
    -
    - +

    The key of the object within the Physics data file that you wish to load the shape data from.

    + - + - + + + options + - -
    + + + +object - - - + + - - - - - - - -
    + - -
    -

    moveDown(speed)

    - - -
    -
    - - -
    -

    If this Body is dynamic then this will move it down by setting its y velocity to the given speed. -The speed is represented in pixels per second. So a value of 100 would move 100 pixels in 1 second (1000ms).

    -
    - - - - - - -
    Parameters:
    - +

    An object containing the build options. Note that this isn't used if the data file contains multiple shapes.

    +
    Properties
    + @@ -7999,8 +8154,12 @@
    Parameters:
    + + + + @@ -8011,23 +8170,127 @@
    Parameters:
    - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + - + + + + + +
    TypeArgumentDefaultDescription
    speedoptimalDecomp + + +boolean + + + + + + <optional>
    + + + + + +
    + + false + +

    Set to true if you need optimal decomposition. Warning: very slow for polygons with more than 10 vertices.

    skipSimpleCheck + + +boolean + + + + + + <optional>
    + + + + + +
    + + false + +

    Set to true if you already know that the path is not intersecting itself.

    removeCollinearPoints -number +boolean +| + +number + + + + + + <optional>
    + + + +
    + + false + +

    The speed at which it should move down, in pixels per second.

    Set to a number (angle threshold value) to remove collinear points, or false to keep all points.

    + + @@ -8059,7 +8322,7 @@
    Parameters:
    Source:
    @@ -8080,6 +8343,29 @@
    Parameters:
    +
    Returns:
    + + +
    +

    True on success, else false.

    +
    + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + @@ -8087,7 +8373,7 @@
    Parameters:
    -

    moveForward(speed)

    +

    loadPolygon(key, object, options) → {boolean}

    @@ -8095,8 +8381,8 @@

    moveForwar
    -

    Moves the Body forwards based on its current angle and the given speed. -The speed is represented in pixels per second. So a value of 100 would move 100 pixels in 1 second (1000ms).

    +

    Reads the physics data from a physics data file stored in the Game.Cache. +It will add the shape data to this Body, as well as set the density (mass), friction and bounce (restitution) values.

    @@ -8130,13 +8416,13 @@

    Parameters:
    - speed + key -number +string @@ -8146,86 +8432,55 @@
    Parameters:
    -

    The speed at which it should move forwards.

    +

    The key of the Physics Data file as stored in Game.Cache.

    - - - - - - -
    - - - - - - + + + object + - + + + +string - - + + - + - + - -
    Source:
    -
    - +

    The key of the object within the Physics data file that you wish to load the shape data from.

    + - + - + + + options + - -
    + + + +object - - - + + - - - - - - - - + - -
    -

    moveLeft(speed)

    - - -
    -
    - - -
    -

    If this Body is dynamic then this will move it to the left by setting its x velocity to the given speed. -The speed is represented in pixels per second. So a value of 100 would move 100 pixels in 1 second (1000ms).

    -
    - - - - - - -
    Parameters:
    - +

    An object containing the build options:

    +
    Properties
    + @@ -8237,8 +8492,12 @@
    Parameters:
    + + + + @@ -8249,12 +8508,93 @@
    Parameters:
    - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + +
    TypeArgumentDefaultDescription
    speedoptimalDecomp + + +boolean + + + + + + <optional>
    + + + + + +
    + + false + +

    Set to true if you need optimal decomposition. Warning: very slow for polygons with more than 10 vertices.

    skipSimpleCheck + + +boolean + + + + + + <optional>
    + + + + + +
    + + false + +

    Set to true if you already know that the path is not intersecting itself.

    removeCollinearPoints +boolean +| + number @@ -8262,10 +8602,33 @@
    Parameters:
    + + <optional>
    + + + + + +
    + + false + +

    The speed at which it should move to the left, in pixels per second.

    Set to a number (angle threshold value) to remove collinear points, or false to keep all points.

    + + @@ -8297,7 +8660,7 @@
    Parameters:
    Source:
    @@ -8318,6 +8681,29 @@
    Parameters:
    +
    Returns:
    + + +
    +

    True on success, else false.

    +
    + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + @@ -8325,7 +8711,7 @@
    Parameters:
    -

    moveRight(speed)

    +

    moveBackward(speed)

    @@ -8333,7 +8719,7 @@

    moveRight -

    If this Body is dynamic then this will move it to the right by setting its x velocity to the given speed. +

    Moves the Body backwards based on its current angle and the given speed. The speed is represented in pixels per second. So a value of 100 would move 100 pixels in 1 second (1000ms).

    @@ -8384,7 +8770,7 @@
    Parameters:
    -

    The speed at which it should move to the right, in pixels per second.

    +

    The speed at which it should move backwards.

    @@ -8416,7 +8802,7 @@
    Parameters:
    Source:
    @@ -8444,7 +8830,7 @@
    Parameters:
    -

    moveUp(speed)

    +

    moveDown(speed)

    @@ -8452,7 +8838,7 @@

    moveUp -

    If this Body is dynamic then this will move it up by setting its y velocity to the given speed. +

    If this Body is dynamic then this will move it down by setting its y velocity to the given speed. The speed is represented in pixels per second. So a value of 100 would move 100 pixels in 1 second (1000ms).

    @@ -8503,7 +8889,7 @@
    Parameters:
    -

    The speed at which it should move up, in pixels per second.

    +

    The speed at which it should move down, in pixels per second.

    @@ -8535,7 +8921,7 @@
    Parameters:
    Source:
    @@ -8563,7 +8949,7 @@
    Parameters:
    -

    p2px(v) → {number}

    +

    moveForward(speed)

    @@ -8571,7 +8957,8 @@

    p2px -

    Convert p2 physics value (meters) to pixel scale.

    +

    Moves the Body forwards based on its current angle and the given speed. +The speed is represented in pixels per second. So a value of 100 would move 100 pixels in 1 second (1000ms).

    @@ -8605,7 +8992,7 @@
    Parameters:
    - v + speed @@ -8621,7 +9008,7 @@
    Parameters:
    -

    The value to convert.

    +

    The speed at which it should move forwards.

    @@ -8653,7 +9040,7 @@
    Parameters:
    Source:
    @@ -8674,29 +9061,6 @@
    Parameters:
    -
    Returns:
    - - -
    -

    The scaled value.

    -
    - - - -
    -
    - Type -
    -
    - -number - - -
    -
    - - - @@ -8704,7 +9068,7 @@
    Returns:
    -

    p2pxi(v) → {number}

    +

    moveLeft(speed)

    @@ -8712,7 +9076,8 @@

    p2pxi -

    Convert p2 physics value (meters) to pixel scale and inverses it.

    +

    If this Body is dynamic then this will move it to the left by setting its x velocity to the given speed. +The speed is represented in pixels per second. So a value of 100 would move 100 pixels in 1 second (1000ms).

    @@ -8746,7 +9111,7 @@
    Parameters:
    - v + speed @@ -8762,7 +9127,7 @@
    Parameters:
    -

    The value to convert.

    +

    The speed at which it should move to the left, in pixels per second.

    @@ -8794,7 +9159,7 @@
    Parameters:
    Source:
    @@ -8815,29 +9180,6 @@
    Parameters:
    -
    Returns:
    - - -
    -

    The scaled value.

    -
    - - - -
    -
    - Type -
    -
    - -number - - -
    -
    - - - @@ -8845,7 +9187,7 @@
    Returns:
    -

    <protected> postUpdate()

    +

    moveRight(speed)

    @@ -8853,7 +9195,8 @@

    <protected> -

    Internal method. This is called directly before the sprites are sent to the renderer and after the update function has finished.

    +

    If this Body is dynamic then this will move it to the right by setting its x velocity to the given speed. +The speed is represented in pixels per second. So a value of 100 would move 100 pixels in 1 second (1000ms).

    @@ -8862,77 +9205,57 @@

    <protected> - - - - - +
    Parameters:
    + - + + + + + + - + - + - + - + + + - + + - -
    Source:
    -
    - + + + + - + - - + - + - - - - - - - - + + - - -
    -

    <protected> preUpdate()

    - - -
    -
    - - -
    -

    Internal method. This is called directly before the sprites are sent to the renderer and after the update function has finished.

    -
    - + +
    +
    NameTypeDescription
    speed + + +number - - - + +

    The speed at which it should move to the right, in pixels per second.

    - - - -
    @@ -8955,7 +9278,7 @@

    <protected> Source:
    @@ -8983,7 +9306,7 @@

    <protected> -

    px2p(v) → {number}

    +

    moveUp(speed)

    @@ -8991,7 +9314,8 @@

    px2p -

    Convert pixel value to p2 physics scale (meters).

    +

    If this Body is dynamic then this will move it up by setting its y velocity to the given speed. +The speed is represented in pixels per second. So a value of 100 would move 100 pixels in 1 second (1000ms).

    @@ -9025,7 +9349,7 @@
    Parameters:
    - v + speed @@ -9041,7 +9365,7 @@
    Parameters:
    -

    The value to convert.

    +

    The speed at which it should move up, in pixels per second.

    @@ -9073,7 +9397,7 @@
    Parameters:
    Source:
    @@ -9094,29 +9418,6 @@
    Parameters:
    -
    Returns:
    - - -
    -

    The scaled value.

    -
    - - - -
    -
    - Type -
    -
    - -number - - -
    -
    - - - @@ -9124,7 +9425,7 @@
    Returns:
    -

    px2pi(v) → {number}

    +

    <protected> postUpdate()

    @@ -9132,7 +9433,7 @@

    px2pi -

    Convert pixel value to p2 physics scale (meters) and inverses it.

    +

    Internal method. This is called directly before the sprites are sent to the renderer and after the update function has finished.

    @@ -9141,54 +9442,74 @@

    px2piParameters:

    - + + +
    + - - - - - - + - + - + - + - - - + - - + - - - - + - + - + + + + + + + + + +
    +

    <protected> preUpdate()

    + + +
    +
    + + +
    +

    Internal method. This is called directly before the sprites are sent to the renderer and after the update function has finished.

    +
    + -
    - - - - -
    NameTypeDescription
    v - - -number + + + +
    Source:
    +
    + + + + + + + + + + - -

    The value to convert.

    - + + + + @@ -9214,7 +9535,7 @@
    Parameters:
    Source:
    @@ -9235,29 +9556,6 @@
    Parameters:
    -
    Returns:
    - - -
    -

    The scaled value.

    -
    - - - -
    -
    - Type -
    -
    - -number - - -
    -
    - - - @@ -9306,7 +9604,7 @@

    remove
    Source:
    @@ -9436,7 +9734,7 @@

    Parameters:
    Source:
    @@ -9706,7 +10004,7 @@
    Parameters:
    Source:
    @@ -9825,7 +10123,7 @@
    Parameters:
    Source:
    @@ -9943,7 +10241,7 @@
    Parameters:
    Source:
    @@ -10061,7 +10359,7 @@
    Parameters:
    Source:
    @@ -10312,7 +10610,7 @@
    Parameters:
    Source:
    @@ -10391,10 +10689,7 @@
    Parameters:
    -Phaser.Physics.CollisionGroup -| - -array +Phaser.Physics.CollisionGroup @@ -10477,7 +10772,7 @@
    Parameters:
    Source:
    @@ -10556,7 +10851,7 @@
    Parameters:
    -Phaser.Physics.Material +Phaser.Physics.Material @@ -10639,7 +10934,7 @@
    Parameters:
    Source:
    @@ -10934,7 +11229,7 @@
    Parameters:
    Source:
    @@ -11092,7 +11387,7 @@
    Parameters:
    Source:
    @@ -11184,7 +11479,7 @@

    setZero
    Source:
    @@ -11253,7 +11548,7 @@

    setZeroFo
    Source:
    @@ -11322,7 +11617,7 @@

    setZer
    Source:
    @@ -11391,7 +11686,76 @@

    setZer
    Source:
    + + + + + + + +

    + + + + + + + + + + + + + + + + + +
    +

    shapeChanged()

    + + +
    +
    + + +
    +

    Updates the debug draw if any body shapes change.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    @@ -11510,7 +11874,7 @@
    Parameters:
    Source:
    @@ -11657,7 +12021,7 @@
    Parameters:
    Source:
    @@ -11798,7 +12162,137 @@
    Parameters:
    Source:
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    updateCollisionMask(shape)

    + + +
    +
    + + +
    +

    Updates the collisionMask.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDescription
    shape + + +p2.Shape + + + + + + <optional>
    + + + + + +

    An optional Shape. If not provided the collision group will be added to all Shapes in this Body.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    @@ -11849,7 +12343,7 @@
    Parameters:
    Documentation generated by JSDoc 3.3.0-dev - on Mon Feb 24 2014 12:11:42 GMT-0000 (GMT) using the DocStrap template. + on Fri Mar 14 2014 06:34:29 GMT-0000 (GMT) using the DocStrap template. @@ -11880,6 +12374,9 @@
    Parameters:
    + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.Physics.CollisionGroup.html b/docs/Phaser.Physics.P2.CollisionGroup.html similarity index 84% rename from docs/Phaser.Physics.CollisionGroup.html rename to docs/Phaser.Physics.P2.CollisionGroup.html index f9d68a9716..ca1aacf717 100644 --- a/docs/Phaser.Physics.CollisionGroup.html +++ b/docs/Phaser.Physics.P2.CollisionGroup.html @@ -58,10 +58,6 @@ BitmapData -
  • - BitmapFont -
  • -
  • BitmapText
  • @@ -259,35 +255,83 @@
  • - Body + Body +
  • + +
  • + Ninja +
  • + +
  • + AABB +
  • + +
  • + Body +
  • + +
  • + Circle +
  • + +
  • + Tile +
  • + +
  • + P2 +
  • + +
  • + Body +
  • + +
  • + BodyDebug +
  • + +
  • + CollisionGroup +
  • + +
  • + ContactMaterial +
  • + +
  • + DistanceConstraint +
  • + +
  • + GearConstraint
  • - CollisionGroup + InversePointProxy
  • - ContactMaterial + LockConstraint
  • - InversePointProxy + Material
  • - Material + PointProxy
  • - PointProxy + PrismaticConstraint
  • - Spring + RevoluteConstraint
  • - World + Spring
  • @@ -310,6 +354,10 @@ Polygon
  • +
  • + QuadTree +
  • +
  • RandomDataGenerator
  • @@ -326,6 +374,14 @@ RequestAnimationFrame +
  • + RetroFont +
  • + +
  • + ScaleManager +
  • +
  • Signal
  • @@ -354,10 +410,6 @@ Stage -
  • - StageScaleMode -
  • -
  • State
  • @@ -438,40 +490,6 @@ - - @@ -490,7 +508,7 @@

    Class: CollisionGroup

    - Phaser.Physics. + Phaser.Physics.P2. CollisionGroup

    @@ -547,7 +565,7 @@

    new Col
    Source:
    @@ -675,7 +693,7 @@

    Properties:
    Source:
    @@ -718,7 +736,7 @@
    Properties:
    Documentation generated by JSDoc 3.3.0-dev - on Mon Feb 24 2014 12:11:43 GMT-0000 (GMT) using the DocStrap template. + on Fri Mar 14 2014 06:34:29 GMT-0000 (GMT) using the DocStrap template. @@ -749,6 +767,9 @@
    Properties:
    + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/global.html b/docs/Phaser.Physics.P2.GearConstraint.html similarity index 65% rename from docs/global.html rename to docs/Phaser.Physics.P2.GearConstraint.html index 33e6a813e1..b4b6f7b5c8 100644 --- a/docs/global.html +++ b/docs/Phaser.Physics.P2.GearConstraint.html @@ -3,7 +3,7 @@ - Phaser Global + Phaser Class: GearConstraint + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: LockConstraint

    +
    + +
    +

    + Phaser.Physics.P2. + + LockConstraint +

    + +

    Physics LockConstraint Constructor

    + +
    + +
    +
    + + + + +
    +

    new LockConstraint(world, bodyA, bodyB, offset, angle, maxForce)

    + + +
    +
    + + +
    +

    Locks the relative position between two bodies.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    world + + +Phaser.Physics.P2 + + + + + + + + + + + +

    A reference to the P2 World.

    bodyA + + +p2.Body + + + + + + + + + + + +

    First connected body.

    bodyB + + +p2.Body + + + + + + + + + + + +

    Second connected body.

    offset + + +Array + + + + + + <optional>
    + + + + + +
    + +

    The offset of bodyB in bodyA's frame. The value is an array with 2 elements matching x and y, i.e: [32, 32].

    angle + + +number + + + + + + <optional>
    + + + + + +
    + + 0 + +

    The angle of bodyB in bodyA's frame.

    maxForce + + +number + + + + + + <optional>
    + + + + + +
    + +

    The maximum force that should be applied to constrain the bodies.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + +

    Members

    + +
    + +
    +

    game

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    Local reference to game.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    world

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    world + + +Phaser.Physics.P2 + + + +

    Local reference to P2 World.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + +
    + + + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2014 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Mar 14 2014 06:34:30 GMT-0000 (GMT) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.Physics.Material.html b/docs/Phaser.Physics.P2.Material.html similarity index 85% rename from docs/Phaser.Physics.Material.html rename to docs/Phaser.Physics.P2.Material.html index f397e6717a..0cb6e851fc 100644 --- a/docs/Phaser.Physics.Material.html +++ b/docs/Phaser.Physics.P2.Material.html @@ -58,10 +58,6 @@ BitmapData -
  • - BitmapFont -
  • -
  • BitmapText
  • @@ -259,35 +255,83 @@
  • - Body + Body +
  • + +
  • + Ninja +
  • + +
  • + AABB +
  • + +
  • + Body +
  • + +
  • + Circle +
  • + +
  • + Tile +
  • + +
  • + P2 +
  • + +
  • + Body +
  • + +
  • + BodyDebug +
  • + +
  • + CollisionGroup +
  • + +
  • + ContactMaterial +
  • + +
  • + DistanceConstraint +
  • + +
  • + GearConstraint
  • - CollisionGroup + InversePointProxy
  • - ContactMaterial + LockConstraint
  • - InversePointProxy + Material
  • - Material + PointProxy
  • - PointProxy + PrismaticConstraint
  • - Spring + RevoluteConstraint
  • - World + Spring
  • @@ -310,6 +354,10 @@ Polygon
  • +
  • + QuadTree +
  • +
  • RandomDataGenerator
  • @@ -326,6 +374,14 @@ RequestAnimationFrame +
  • + RetroFont +
  • + +
  • + ScaleManager +
  • +
  • Signal
  • @@ -354,10 +410,6 @@ Stage -
  • - StageScaleMode -
  • -
  • State
  • @@ -438,40 +490,6 @@ - - @@ -490,7 +508,7 @@

    Class: Material

    - Phaser.Physics. + Phaser.Physics.P2. Material

    @@ -547,7 +565,7 @@

    new Material<
    Source:
    @@ -678,7 +696,7 @@

    Properties:
    Source:
    @@ -721,7 +739,7 @@
    Properties:
    Documentation generated by JSDoc 3.3.0-dev - on Mon Feb 24 2014 12:11:43 GMT-0000 (GMT) using the DocStrap template. + on Fri Mar 14 2014 06:34:30 GMT-0000 (GMT) using the DocStrap template. @@ -752,6 +770,9 @@
    Properties:
    + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.Physics.P2.RevoluteConstraint.html b/docs/Phaser.Physics.P2.RevoluteConstraint.html new file mode 100644 index 0000000000..090aaed838 --- /dev/null +++ b/docs/Phaser.Physics.P2.RevoluteConstraint.html @@ -0,0 +1,1133 @@ + + + + + + Phaser Class: RevoluteConstraint + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: RevoluteConstraint

    +
    + +
    +

    + Phaser.Physics.P2. + + RevoluteConstraint +

    + +

    Physics RevoluteConstraint Constructor

    + +
    + +
    +
    + + + + +
    +

    new RevoluteConstraint(world, bodyA, pivotA, bodyB, pivotB, maxForce)

    + + +
    +
    + + +
    +

    Connects two bodies at given offset points, letting them rotate relative to each other around this point. +The pivot points are given in world (pixel) coordinates.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    world + + +Phaser.Physics.P2 + + + + + + + + + + + +

    A reference to the P2 World.

    bodyA + + +p2.Body + + + + + + + + + + + +

    First connected body.

    pivotA + + +Float32Array + + + + + + + + + + + +

    The point relative to the center of mass of bodyA which bodyA is constrained to. The value is an array with 2 elements matching x and y, i.e: [32, 32].

    bodyB + + +p2.Body + + + + + + + + + + + +

    Second connected body.

    pivotB + + +Float32Array + + + + + + + + + + + +

    The point relative to the center of mass of bodyB which bodyB is constrained to. The value is an array with 2 elements matching x and y, i.e: [32, 32].

    maxForce + + +number + + + + + + <optional>
    + + + + + +
    + + 0 + +

    The maximum force that should be applied to constrain the bodies.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + +

    Members

    + +
    + +
    +

    game

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    Local reference to game.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    world

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    world + + +Phaser.Physics.P2 + + + +

    Local reference to P2 World.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + +
    + + + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2014 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Mar 14 2014 06:34:31 GMT-0000 (GMT) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.Physics.Spring.html b/docs/Phaser.Physics.P2.Spring.html similarity index 79% rename from docs/Phaser.Physics.Spring.html rename to docs/Phaser.Physics.P2.Spring.html index 2dbb280d3b..eea80eedbe 100644 --- a/docs/Phaser.Physics.Spring.html +++ b/docs/Phaser.Physics.P2.Spring.html @@ -58,10 +58,6 @@ BitmapData -
  • - BitmapFont -
  • -
  • BitmapText
  • @@ -259,35 +255,83 @@
  • - Body + Body +
  • + +
  • + Ninja +
  • + +
  • + AABB +
  • + +
  • + Body
  • - CollisionGroup + Circle
  • - ContactMaterial + Tile
  • - InversePointProxy + P2
  • - Material + Body
  • - PointProxy + BodyDebug
  • - Spring + CollisionGroup
  • - World + ContactMaterial +
  • + +
  • + DistanceConstraint +
  • + +
  • + GearConstraint +
  • + +
  • + InversePointProxy +
  • + +
  • + LockConstraint +
  • + +
  • + Material +
  • + +
  • + PointProxy +
  • + +
  • + PrismaticConstraint +
  • + +
  • + RevoluteConstraint +
  • + +
  • + Spring
  • @@ -310,6 +354,10 @@ Polygon
  • +
  • + QuadTree +
  • +
  • RandomDataGenerator
  • @@ -326,6 +374,14 @@ RequestAnimationFrame +
  • + RetroFont +
  • + +
  • + ScaleManager +
  • +
  • Signal
  • @@ -354,10 +410,6 @@ Stage -
  • - StageScaleMode -
  • -
  • State
  • @@ -438,40 +490,6 @@ - - @@ -490,7 +508,7 @@

    Class: Spring

    - Phaser.Physics. + Phaser.Physics.P2. Spring

    @@ -506,7 +524,7 @@

    -

    new Spring(game, bodyA, bodyB, restLength, stiffness, damping, worldA, worldB, localA, localB)

    +

    new Spring(world, bodyA, bodyB, restLength, stiffness, damping, worldA, worldB, localA, localB)

    @@ -514,7 +532,7 @@

    new Spring -

    Creates a spring, connecting two bodies.

    +

    Creates a spring, connecting two bodies. A spring can have a resting length, a stiffness and damping.

    @@ -552,13 +570,13 @@
    Parameters:
    - game + world -Phaser.Game +Phaser.Physics.P2 @@ -580,7 +598,7 @@
    Parameters:
    -

    A reference to the current game.

    +

    A reference to the P2 World.

    @@ -593,7 +611,7 @@
    Parameters:
    -p2.Body +p2.Body @@ -628,7 +646,7 @@
    Parameters:
    -p2.Body +p2.Body @@ -804,7 +822,7 @@
    Parameters:
    -

    Where to hook the spring to body A, in world coordinates, i.e. [32, 32].

    +

    Where to hook the spring to body A in world coordinates. This value is an array with 2 elements matching x and y, i.e: [32, 32].

    @@ -841,7 +859,7 @@
    Parameters:
    -

    Where to hook the spring to body B, in world coordinates, i.e. [32, 32].

    +

    Where to hook the spring to body B in world coordinates. This value is an array with 2 elements matching x and y, i.e: [32, 32].

    @@ -878,7 +896,7 @@
    Parameters:
    -

    Where to hook the spring to body A, in local body coordinates.

    +

    Where to hook the spring to body A in local body coordinates. This value is an array with 2 elements matching x and y, i.e: [32, 32].

    @@ -915,7 +933,7 @@
    Parameters:
    -

    Where to hook the spring to body B, in local body coordinates.

    +

    Where to hook the spring to body B in local body coordinates. This value is an array with 2 elements matching x and y, i.e: [32, 32].

    @@ -947,7 +965,7 @@
    Parameters:
    Source:
    @@ -1075,7 +1093,109 @@
    Properties:
    Source:
    + + + + + + + +

    + + + +
    + + + +
    +

    world

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    world + + +Phaser.Physics.P2 + + + +

    Local reference to P2 World.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    @@ -1118,7 +1238,7 @@
    Properties:
    Documentation generated by JSDoc 3.3.0-dev - on Mon Feb 24 2014 12:11:43 GMT-0000 (GMT) using the DocStrap template. + on Fri Mar 14 2014 06:34:31 GMT-0000 (GMT) using the DocStrap template. @@ -1149,6 +1269,9 @@
    Properties:
    + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.Physics.html b/docs/Phaser.Physics.html index 79274a3174..490596aaff 100644 --- a/docs/Phaser.Physics.html +++ b/docs/Phaser.Physics.html @@ -58,10 +58,6 @@ BitmapData -
  • - BitmapFont -
  • -
  • BitmapText
  • @@ -259,35 +255,83 @@
  • - Body + Body +
  • + +
  • + Ninja +
  • + +
  • + AABB +
  • + +
  • + Body +
  • + +
  • + Circle +
  • + +
  • + Tile +
  • + +
  • + P2 +
  • + +
  • + Body +
  • + +
  • + BodyDebug +
  • + +
  • + CollisionGroup +
  • + +
  • + ContactMaterial +
  • + +
  • + DistanceConstraint
  • - CollisionGroup + GearConstraint
  • - ContactMaterial + InversePointProxy
  • - InversePointProxy + LockConstraint
  • - Material + Material
  • - PointProxy + PointProxy
  • - Spring + PrismaticConstraint
  • - World + RevoluteConstraint +
  • + +
  • + Spring
  • @@ -310,6 +354,10 @@ Polygon
  • +
  • + QuadTree +
  • +
  • RandomDataGenerator
  • @@ -326,6 +374,14 @@ RequestAnimationFrame +
  • + RetroFont +
  • + +
  • + ScaleManager +
  • +
  • Signal
  • @@ -354,10 +410,6 @@ Stage -
  • - StageScaleMode -
  • -
  • State
  • @@ -438,40 +490,6 @@ - - @@ -495,6 +513,8 @@

    Physics

    +

    Phaser.Physics

    +

    @@ -504,19 +524,131 @@

    -

    new Physics()

    +

    new Physics(game, physicsConfig)

    +
    +

    The Physics Manager is responsible for looking after all of the running physics systems. +Phaser supports 3 physics systems: Arcade Physics, P2 and Ninja Physics (with Box2D and Chipmunk in development) +Game Objects can belong to only 1 physics system, but you can have multiple systems active in a single game.

    +

    For example you could have P2 managing a polygon-built terrain landscape that an vehicle drives over, while it could be firing bullets that use the +faster (due to being much simpler) Arcade Physics system.

    +
    + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    game + + +Phaser.Game + + + + + + + + + + + +

    A reference to the currently running game.

    physicsConfig + + +object + + + + + + <optional>
    + + + + + +
    + + null + +

    A physics configuration object to pass to the Physics world on creation.

    + +
    @@ -541,7 +673,7 @@

    new PhysicsSource:
    @@ -582,28 +714,10 @@

    Classes

    Arcade
    -
    Body
    -
    - -
    CollisionGroup
    -
    - -
    ContactMaterial
    -
    - -
    InversePointProxy
    -
    - -
    Material
    -
    - -
    PointProxy
    -
    - -
    Spring
    +
    Ninja
    -
    World
    +
    P2

    @@ -616,7 +730,7 @@

    Members

    -

    <static, constant> LIME_CORONA_JSON :number

    +

    <static, constant> ARCADE :number

    @@ -658,7 +772,7 @@
    Type:
    Source:
    @@ -673,260 +787,1057 @@
    Type:
    - - - - -

    Methods

    - -
    +
    -

    setBoundsToWorld(left, right, top, bottom, setCollisionGroup)

    +

    <static, constant> BOX2D :number

    -
    -

    Sets the bounds of the Physics world to match the Game.World dimensions. -You can optionally set which 'walls' to create: left, right, top or bottom.

    -
    +
    Type:
    +
      +
    • + +number + +
    • +
    + +
    + + -
    Parameters:
    - - - - - - - + - + - - - + - - - + - - - + - - + - - - - + +
    Source:
    +
    + - +
    +

    ninja

    + + +
    +
    + + + - -
    - +
    - -
    - +
    NameTypeArgumentDefaultDescription
    left - - -boolean + + + + + + + + + + + + +
    +

    <static, constant> CHIPMUNK :number

    + + +
    +
    + + + +
    Type:
    +
      +
    • + +number + + +
    • +
    + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <static, constant> NINJA :number

    + + +
    +
    + + + +
    Type:
    +
      +
    • + +number + + +
    • +
    + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <static, constant> P2JS :number

    + + +
    +
    + + + +
    Type:
    +
      +
    • + +number + + +
    • +
    + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    arcade

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    arcade + + +Phaser.Physics.Arcade + + + +

    The Arcade Physics system.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    box2d

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    box2d + + +Phaser.Physics.Box2D + + + +

    The Box2D Physics system (to be done).

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    chipmunk

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    chipmunk + + +Phaser.Physics.Chipmunk + + + +

    The Chipmunk Physics system (to be done).

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    config

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    config + + +object + + + +

    The physics configuration object as passed to the game on creation.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    game

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    Local reference to game.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + -
    - - <optional>
    - + +
    + - +
    Properties:
    - -
    - - true - -
    + + + + + - - + + + + + + + + + + - + - - - - - + + +
    Name

    If true will create the left bounds wall.

    TypeDescription
    rightninja -boolean +Phaser.Physics.Ninja - - <optional>
    - - - - - -
    - - true - -

    If true will create the right bounds wall.

    The N+ Ninja Physics System.

    +
    - - - top - + - - - -boolean + + - - + - - - - <optional>
    - + - + - - - + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + - - - true - - - +
    +

    p2

    + + +
    +
    + + + -

    If true will create the top bounds wall.

    - + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + - + - - - - - + + +
    NameTypeDescription
    bottomp2 -boolean +Phaser.Physics.P2 - - <optional>
    - - - - - -
    - - true - -

    If true will create the bottom bounds wall.

    The P2.JS Physics system.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + + + +

    Methods

    + +
    + +
    +

    <protected> clear()

    + + +
    +
    + + +
    +

    Clears down all active physics systems. This doesn't destroy them, it just clears them of objects and is called when the State changes.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + - - - setCollisionGroup - + - - - -boolean + + +
    Source:
    +
    + - - + - - - - <optional>
    - + - + +
    - - - + + - - - - true - - - + -

    If true the Bounds will be set to use its own Collision Group.

    - + + + + + + + +
    - - - + + +
    +

    destroy()

    + + +
    +
    + + +
    +

    Destroys all active physics systems. Usually only called on a Game Shutdown, not on a State swap.

    +
    + + + + +
    @@ -949,7 +1860,7 @@
    Parameters:
    Source:
    @@ -977,7 +1888,7 @@
    Parameters:
    -

    setWorldMaterial(material, left, right, top, bottom)

    +

    enable(object, system, debug)

    @@ -985,7 +1896,15 @@

    setWo
    -

    Sets the given material against the 4 bounds of this World.

    +

    This will create a default physics body on the given game object or array of objects. +A game object can only have 1 physics body active at any one time, and it can't be changed until the object is destroyed. +It can be for any of the physics systems that have been started:

    +

    Phaser.Physics.Arcade - A light weight AABB based collision system with basic separation. +Phaser.Physics.P2JS - A full-body advanced physics system supporting multiple object shapes, polygon loading, contact materials, springs and constraints. +Phaser.Physics.NINJA - A port of Metanet Softwares N+ physics system. Advanced AABB and Circle vs. Tile collision. +Phaser.Physics.BOX2D and Phaser.Physics.CHIPMUNK are still in development.

    +

    If you require more control over what type of body is created, for example to create a Ninja Physics Circle instead of the default AABB, then see the +individual physics systems enable methods instead of using this generic one.

    @@ -1023,87 +1942,16 @@

    Parameters:
    - material - - - - - -Phaser.Physics.Material - - - - - - - - - - - - - - - - - - - - - -

    The material to set.

    - - - - - - - left + object -boolean - - - - - - - - - <optional>
    - - - - - - - - - - - - true - - - - -

    If true will set the material on the left bounds wall.

    - - - - - - - right - +object +| - - - -boolean +array @@ -1112,8 +1960,6 @@
    Parameters:
    - <optional>
    - @@ -1124,25 +1970,23 @@
    Parameters:
    - true - -

    If true will set the material on the right bounds wall.

    +

    The game object to create the physics body on. Can also be an array of objects, a body will be created on every object in the array.

    - top + system -boolean +number @@ -1163,19 +2007,19 @@
    Parameters:
    - true + Phaser.Physics.ARCADE -

    If true will set the material on the top bounds wall.

    +

    The physics system that will be used to create the body. Defaults to Arcade Physics.

    - bottom + debug @@ -1202,12 +2046,12 @@
    Parameters:
    - true + false -

    If true will set the material on the bottom bounds wall.

    +

    Enable the debug drawing for this body. Defaults to false.

    @@ -1239,7 +2083,7 @@
    Parameters:
    Source:
    @@ -1264,46 +2108,20 @@
    Parameters:
    -
    - - - - - -
    - - - - - - - -

    Class: Physics

    -
    - -
    -

    - Phaser. - - Physics -

    - -
    - -
    -
    - - - +
    -

    new Physics()

    +

    parseConfig()

    +
    +

    Parses the Physics Configuration object passed to the Game constructor and starts any physics systems specified within.

    +
    + @@ -1334,7 +2152,7 @@

    new PhysicsSource:
    @@ -1359,77 +2177,37 @@

    new Physics + + +
    +

    <protected> preUpdate()

    -

    - - + +
    - - +
    +

    preUpdate checks.

    +
    -

    Classes

    -
    -
    Arcade
    -
    - -
    Body
    -
    - -
    CollisionGroup
    -
    - -
    ContactMaterial
    -
    - -
    InversePointProxy
    -
    - -
    Material
    -
    - -
    PointProxy
    -
    - -
    Spring
    -
    - -
    World
    -
    -
    - - -

    Members

    - -
    - -
    -

    <static, constant> LIME_CORONA_JSON :number

    -
    -
    +
    -
    Type:
    -
      -
    • - -number + -
    • -
    -
    + @@ -1441,38 +2219,34 @@
    Type:
    +
    Source:
    +
    + +
    -
    Source:
    -
    - -
    - -
    - -
    - -

    Methods

    + +
    -
    +

    setBoundsToWorld(left, right, top, bottom, setCollisionGroup)

    @@ -1742,7 +2516,76 @@
    Parameters:
    Source:
    + + + + + + + +
    + + + + + + + + + + + + + + + + + +
    +

    <protected> setBoundsToWorld()

    + + +
    +
    + + +
    +

    Updates the physics bounds to match the world dimensions.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    @@ -1822,7 +2665,7 @@
    Parameters:
    -Phaser.Physics.Material +Phaser.Physics.P2.Material @@ -2032,7 +2875,199 @@
    Parameters:
    Source:
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    startSystem(The)

    + + +
    +
    + + +
    +

    This will create an instance of the requested physics simulation. +Phaser.Physics.Arcade is running by default, but all others need activating directly. +You can start the following physics systems: +Phaser.Physics.P2JS - A full-body advanced physics system by Stefan Hedman. +Phaser.Physics.NINJA - A port of Metanet Softwares N+ physics system. +Phaser.Physics.BOX2D and Phaser.Physics.CHIPMUNK are still in development.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    The + + +number + + + +

    physics system to start.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    <protected> update()

    + + +
    +
    + + +
    +

    Updates all running physics systems.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    @@ -2083,7 +3118,7 @@
    Parameters:
    Documentation generated by JSDoc 3.3.0-dev - on Mon Feb 24 2014 12:11:42 GMT-0000 (GMT) using the DocStrap template. + on Fri Mar 14 2014 06:34:27 GMT-0000 (GMT) using the DocStrap template. @@ -2114,6 +3149,9 @@
    Parameters:
    + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.RandomDataGenerator.html b/docs/Phaser.RandomDataGenerator.html index 0920b7b029..93581f2b72 100644 --- a/docs/Phaser.RandomDataGenerator.html +++ b/docs/Phaser.RandomDataGenerator.html @@ -58,10 +58,6 @@ BitmapData -
  • - BitmapFont -
  • -
  • BitmapText
  • @@ -259,35 +255,83 @@
  • - Body + Body +
  • + +
  • + Ninja +
  • + +
  • + AABB +
  • + +
  • + Body +
  • + +
  • + Circle +
  • + +
  • + Tile +
  • + +
  • + P2 +
  • + +
  • + Body +
  • + +
  • + BodyDebug +
  • + +
  • + CollisionGroup +
  • + +
  • + ContactMaterial +
  • + +
  • + DistanceConstraint +
  • + +
  • + GearConstraint
  • - CollisionGroup + InversePointProxy
  • - ContactMaterial + LockConstraint
  • - InversePointProxy + Material
  • - Material + PointProxy
  • - PointProxy + PrismaticConstraint
  • - Spring + RevoluteConstraint
  • - World + Spring
  • @@ -310,6 +354,10 @@ Polygon
  • +
  • + QuadTree +
  • +
  • RandomDataGenerator
  • @@ -326,6 +374,14 @@ RequestAnimationFrame +
  • + RetroFont +
  • + +
  • + ScaleManager +
  • +
  • Signal
  • @@ -354,10 +410,6 @@ Stage -
  • - StageScaleMode -
  • -
  • State
  • @@ -438,40 +490,6 @@ - - @@ -685,7 +703,7 @@

    angleSource:
    @@ -928,7 +946,7 @@

    integer
    -

    Returns a random integer between min and max.

    +

    Returns a random integer between and including min and max.

    @@ -1125,7 +1143,7 @@

    normalSource:
    @@ -1266,7 +1284,7 @@
    Parameters:
    Source:
    @@ -1522,7 +1540,7 @@
    Parameters:
    Source:
    @@ -1804,7 +1822,7 @@
    Parameters:
    Source:
    @@ -1896,7 +1914,7 @@

    uuidSource:
    @@ -2037,7 +2055,7 @@
    Parameters:
    Source:
    @@ -2111,7 +2129,7 @@
    Returns:
    Documentation generated by JSDoc 3.3.0-dev - on Mon Feb 24 2014 12:11:44 GMT-0000 (GMT) using the DocStrap template. + on Fri Mar 14 2014 06:34:32 GMT-0000 (GMT) using the DocStrap template. @@ -2142,6 +2160,9 @@
    Returns:
    + + + + + + + + + + + + + + + + + + + diff --git a/docs/Plugin.js.html b/docs/Plugin.js.html index ba57b9ab58..794f5cb869 100644 --- a/docs/Plugin.js.html +++ b/docs/Plugin.js.html @@ -58,10 +58,6 @@ BitmapData -
  • - BitmapFont -
  • -
  • BitmapText
  • @@ -259,35 +255,83 @@
  • - Body + Body +
  • + +
  • + Ninja +
  • + +
  • + AABB +
  • + +
  • + Body +
  • + +
  • + Circle +
  • + +
  • + Tile +
  • + +
  • + P2 +
  • + +
  • + Body +
  • + +
  • + BodyDebug +
  • + +
  • + CollisionGroup +
  • + +
  • + ContactMaterial +
  • + +
  • + DistanceConstraint +
  • + +
  • + GearConstraint
  • - CollisionGroup + InversePointProxy
  • - ContactMaterial + LockConstraint
  • - InversePointProxy + Material
  • - Material + PointProxy
  • - PointProxy + PrismaticConstraint
  • - Spring + RevoluteConstraint
  • - World + Spring
  • @@ -310,6 +354,10 @@ Polygon
  • +
  • + QuadTree +
  • +
  • RandomDataGenerator
  • @@ -326,6 +374,14 @@ RequestAnimationFrame +
  • + RetroFont +
  • + +
  • + ScaleManager +
  • +
  • Signal
  • @@ -354,10 +410,6 @@ Stage -
  • - StageScaleMode -
  • -
  • State
  • @@ -438,40 +490,6 @@ - - @@ -633,7 +651,7 @@

    Source: core/Plugin.js

    Documentation generated by JSDoc 3.3.0-dev - on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template. + on Fri Mar 14 2014 06:34:18 GMT-0000 (GMT) using the DocStrap template. @@ -660,6 +678,9 @@

    Source: core/Plugin.js

    + + + + + + + + + + + + + + + + + + + diff --git a/docs/QuadTree.js.html b/docs/QuadTree.js.html new file mode 100644 index 0000000000..ea67e2a15f --- /dev/null +++ b/docs/QuadTree.js.html @@ -0,0 +1,910 @@ + + + + + + Phaser Source: math/QuadTree.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: math/QuadTree.js

    + +
    +
    +
    /**
    + * @author       Richard Davey <rich@photonstorm.com>
    + * @copyright    2014 Photon Storm Ltd.
    + * @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    + */
    +
    +/**
    +* Javascript QuadTree
    +* @version 1.0
    +* @author Timo Hausmann
    +*
    +* @version 1.3, March 11th 2014
    +* @author Richard Davey
    +* The original code was a conversion of the Java code posted to GameDevTuts. However I've tweaked
    +* it massively to add node indexing, removed lots of temp. var creation and significantly
    +* increased performance as a result.
    +*
    +* Original version at https://github.com/timohausmann/quadtree-js/
    +*/
    +
    +/**
    +* @copyright © 2012 Timo Hausmann
    +*
    +* Permission is hereby granted, free of charge, to any person obtaining
    +* a copy of this software and associated documentation files (the
    +* "Software"), to deal in the Software without restriction, including
    +* without limitation the rights to use, copy, modify, merge, publish,
    +* distribute, sublicense, and/or sell copies of the Software, and to
    +* permit persons to whom the Software is furnished to do so, subject to
    +* the following conditions:
    +*
    +* The above copyright notice and this permission notice shall be
    +* included in all copies or substantial portions of the Software.
    +*
    +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
    +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
    +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
    +* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
    +* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
    +* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
    +* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    +*/
    +
    +/**
    +* QuadTree Constructor
    +*
    +* @class Phaser.QuadTree
    +* @classdesc A QuadTree implementation. The original code was a conversion of the Java code posted to GameDevTuts.
    +* However I've tweaked it massively to add node indexing, removed lots of temp. var creation and significantly increased performance as a result.
    +* Original version at https://github.com/timohausmann/quadtree-js/
    +* @constructor
    +* @param {number} x - The top left coordinate of the quadtree.
    +* @param {number} y - The top left coordinate of the quadtree.
    +* @param {number} width - The width of the quadtree in pixels.
    +* @param {number} height - The height of the quadtree in pixels.
    +* @param {number} [maxObjects=10] - The maximum number of objects per node.
    +* @param {number} [maxLevels=4] - The maximum number of levels to iterate to.
    +* @param {number} [level=0] - Which level is this?
    +*/
    +Phaser.QuadTree = function(x, y, width, height, maxObjects, maxLevels, level) {
    +
    +    /**
    +    * @property {number} maxObjects - The maximum number of objects per node.
    +    * @default
    +    */
    +    this.maxObjects = 10;
    +
    +    /**
    +    * @property {number} maxLevels - The maximum number of levels to break down to.
    +    * @default
    +    */
    +    this.maxLevels = 4;
    +
    +    /**
    +    * @property {number} level - The current level.
    +    */
    +    this.level = 0;
    +
    +    /**
    +    * @property {object} bounds - Object that contains the quadtree bounds.
    +    */
    +    this.bounds = {};
    +
    +    /**
    +    * @property {array} objects - Array of quadtree children.
    +    */
    +    this.objects = [];
    +
    +    /**
    +    * @property {array} nodes - Array of associated child nodes.
    +    */
    +    this.nodes = [];
    +
    +    this.reset(x, y, width, height, maxObjects, maxLevels, level);
    +
    +};
    +
    +Phaser.QuadTree.prototype = {
    +
    +    /**
    +    * Resets the QuadTree.
    +    *
    +    * @method Phaser.QuadTree#reset
    +    * @param {number} x - The top left coordinate of the quadtree.
    +    * @param {number} y - The top left coordinate of the quadtree.
    +    * @param {number} width - The width of the quadtree in pixels.
    +    * @param {number} height - The height of the quadtree in pixels.
    +    * @param {number} [maxObjects=10] - The maximum number of objects per node.
    +    * @param {number} [maxLevels=4] - The maximum number of levels to iterate to.
    +    * @param {number} [level=0] - Which level is this?
    +    */
    +    reset: function (x, y, width, height, maxObjects, maxLevels, level) {
    +
    +        this.maxObjects = maxObjects || 10;
    +        this.maxLevels = maxLevels || 4;
    +        this.level = level || 0;
    +
    +        this.bounds = {
    +            x: Math.round(x),
    +            y: Math.round(y),
    +            width: width,
    +            height: height,
    +            subWidth: Math.floor(width / 2),
    +            subHeight: Math.floor(height / 2),
    +            right: Math.round(x) + Math.floor(width / 2),
    +            bottom: Math.round(y) + Math.floor(height / 2)
    +        };
    +
    +        this.objects.length = 0;
    +        this.nodes.length = 0;
    +
    +    },
    +
    +    /**
    +    * Populates this quadtree with the children of the given Group. In order to be added the child must exist and have a body property.
    +    *
    +    * @method Phaser.QuadTree#populate
    +    * @param {Phaser.Group} group - The Group to add to the quadtree.
    +    */
    +    populate: function (group) {
    +
    +        group.forEach(this.populateHandler, this, true);
    +
    +    },
    +
    +    /**
    +    * Handler for the populate method.
    +    *
    +    * @method Phaser.QuadTree#populateHandler
    +    * @param {Phaser.Sprite|object} sprite - The Sprite to check.
    +    */
    +    populateHandler: function (sprite) {
    +
    +        if (sprite.body && sprite.exists)
    +        {
    +            this.insert(sprite.body);
    +        }
    +
    +    },
    +
    +    /**
    +    * Split the node into 4 subnodes
    +    *
    +    * @method Phaser.QuadTree#split
    +    */
    +    split: function () {
    +
    +        this.level++;
    +
    +        //  top right node
    +        this.nodes[0] = new Phaser.QuadTree(this.bounds.right, this.bounds.y, this.bounds.subWidth, this.bounds.subHeight, this.maxObjects, this.maxLevels, this.level);
    +
    +        //  top left node
    +        this.nodes[1] = new Phaser.QuadTree(this.bounds.x, this.bounds.y, this.bounds.subWidth, this.bounds.subHeight, this.maxObjects, this.maxLevels, this.level);
    +
    +        //  bottom left node
    +        this.nodes[2] = new Phaser.QuadTree(this.bounds.x, this.bounds.bottom, this.bounds.subWidth, this.bounds.subHeight, this.maxObjects, this.maxLevels, this.level);
    +
    +        //  bottom right node
    +        this.nodes[3] = new Phaser.QuadTree(this.bounds.right, this.bounds.bottom, this.bounds.subWidth, this.bounds.subHeight, this.maxObjects, this.maxLevels, this.level);
    +
    +    },
    +
    +    /**
    +    * Insert the object into the node. If the node exceeds the capacity, it will split and add all objects to their corresponding subnodes.
    +    *
    +    * @method Phaser.QuadTree#insert
    +    * @param {Phaser.Physics.Arcade.Body|object} body - The Body object to insert into the quadtree. Can be any object so long as it exposes x, y, right and bottom properties.
    +    */
    +    insert: function (body) {
    +
    +        var i = 0;
    +        var index;
    +
    +        //  if we have subnodes ...
    +        if (this.nodes[0] != null)
    +        {
    +            index = this.getIndex(body);
    +
    +            if (index !== -1)
    +            {
    +                this.nodes[index].insert(body);
    +                return;
    +            }
    +        }
    +
    +        this.objects.push(body);
    +
    +        if (this.objects.length > this.maxObjects && this.level < this.maxLevels)
    +        {
    +            //  Split if we don't already have subnodes
    +            if (this.nodes[0] == null)
    +            {
    +                this.split();
    +            }
    +
    +            //  Add objects to subnodes
    +            while (i < this.objects.length)
    +            {
    +                index = this.getIndex(this.objects[i]);
    +
    +                if (index !== -1)
    +                {
    +                    //  this is expensive - see what we can do about it
    +                    this.nodes[index].insert(this.objects.splice(i, 1)[0]);
    +                }
    +                else
    +                {
    +                    i++;
    +                }
    +            }
    +        }
    +
    +    },
    +
    +    /**
    +    * Determine which node the object belongs to.
    +    *
    +    * @method Phaser.QuadTree#getIndex
    +    * @param {Phaser.Rectangle|object} rect - The bounds in which to check.
    +    * @return {number} index - Index of the subnode (0-3), or -1 if rect cannot completely fit within a subnode and is part of the parent node.
    +    */
    +    getIndex: function (rect) {
    +
    +        //  default is that rect doesn't fit, i.e. it straddles the internal quadrants
    +        var index = -1;
    +
    +        if (rect.x < this.bounds.right && rect.right < this.bounds.right)
    +        {
    +            if (rect.y < this.bounds.bottom && rect.bottom < this.bounds.bottom)
    +            {
    +                //  rect fits within the top-left quadrant of this quadtree
    +                index = 1;
    +            }
    +            else if (rect.y > this.bounds.bottom)
    +            {
    +                //  rect fits within the bottom-left quadrant of this quadtree
    +                index = 2;
    +            }
    +        }
    +        else if (rect.x > this.bounds.right)
    +        {
    +            //  rect can completely fit within the right quadrants
    +            if (rect.y < this.bounds.bottom && rect.bottom < this.bounds.bottom)
    +            {
    +                //  rect fits within the top-right quadrant of this quadtree
    +                index = 0;
    +            }
    +            else if (rect.y > this.bounds.bottom)
    +            {
    +                //  rect fits within the bottom-right quadrant of this quadtree
    +                index = 3;
    +            }
    +        }
    +
    +        return index;
    +
    +    },
    +
    +    /**
    +    * Return all objects that could collide with the given Sprite.
    +    *
    +    * @method Phaser.QuadTree#retrieve
    +    * @param {Phaser.Sprite} sprite - The sprite to check against.
    +    * @return {array} - Array with all detected objects.
    +    */
    +    retrieve: function (sprite) {
    +
    +        var returnObjects = this.objects;
    +
    +        // sprite.body.quadTreeIndex = this.getIndex(sprite.body);
    +        var index = this.getIndex(sprite.body);
    +
    +        if (this.nodes[0])
    +        {
    +            //  If rect fits into a subnode ..
    +            if (index !== -1)
    +            {
    +                returnObjects = returnObjects.concat(this.nodes[index].retrieve(sprite));
    +            }
    +            else
    +            {
    +                //  If rect does not fit into a subnode, check it against all subnodes (unrolled for speed)
    +                returnObjects = returnObjects.concat(this.nodes[0].retrieve(sprite));
    +                returnObjects = returnObjects.concat(this.nodes[1].retrieve(sprite));
    +                returnObjects = returnObjects.concat(this.nodes[2].retrieve(sprite));
    +                returnObjects = returnObjects.concat(this.nodes[3].retrieve(sprite));
    +            }
    +        }
    +
    +        return returnObjects;
    +
    +    },
    +
    +    /**
    +    * Clear the quadtree.
    +    * @method Phaser.QuadTree#clear
    +    */
    +    clear: function () {
    +
    +        this.objects.length = 0;
    +
    +        var i = this.nodes.length;
    +
    +        while (i--)
    +        {
    +            this.nodes[i].clear();
    +            this.nodes.splice(i, 1);
    +        }
    +
    +        this.nodes.length = 0;
    +    }
    +
    +};
    +
    +Phaser.QuadTree.prototype.constructor = Phaser.QuadTree;
    +
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2014 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Mar 14 2014 06:34:18 GMT-0000 (GMT) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/RandomDataGenerator.js.html b/docs/RandomDataGenerator.js.html index 28b05229af..07f51e0150 100644 --- a/docs/RandomDataGenerator.js.html +++ b/docs/RandomDataGenerator.js.html @@ -58,10 +58,6 @@ BitmapData -
  • - BitmapFont -
  • -
  • BitmapText
  • @@ -259,35 +255,83 @@
  • - Body + Body +
  • + +
  • + Ninja +
  • + +
  • + AABB +
  • + +
  • + Body +
  • + +
  • + Circle +
  • + +
  • + Tile +
  • + +
  • + P2 +
  • + +
  • + Body +
  • + +
  • + BodyDebug +
  • + +
  • + CollisionGroup +
  • + +
  • + ContactMaterial +
  • + +
  • + DistanceConstraint +
  • + +
  • + GearConstraint
  • - CollisionGroup + InversePointProxy
  • - ContactMaterial + LockConstraint
  • - InversePointProxy + Material
  • - Material + PointProxy
  • - PointProxy + PrismaticConstraint
  • - Spring + RevoluteConstraint
  • - World + Spring
  • @@ -310,6 +354,10 @@ Polygon
  • +
  • + QuadTree +
  • +
  • RandomDataGenerator
  • @@ -326,6 +374,14 @@ RequestAnimationFrame +
  • + RetroFont +
  • + +
  • + ScaleManager +
  • +
  • Signal
  • @@ -354,10 +410,6 @@ Stage -
  • - StageScaleMode -
  • -
  • State
  • @@ -438,40 +490,6 @@ - - @@ -645,14 +663,15 @@

    Source: math/RandomDataGenerator.js

    }, /** - * Returns a random integer between min and max. + * Returns a random integer between and including min and max. + * * @method Phaser.RandomDataGenerator#integerInRange * @param {number} min - The minimum value in the range. * @param {number} max - The maximum value in the range. * @return {number} A random number between min and max. */ integerInRange: function (min, max) { - return Math.floor(this.realInRange(min, max)); + return Math.round(this.realInRange(min, max)); }, /** @@ -702,7 +721,7 @@

    Source: math/RandomDataGenerator.js

    * @return {any} A random member of the array. */ pick: function (ary) { - return ary[this.integerInRange(0, ary.length)]; + return ary[this.integerInRange(0, ary.length - 1)]; }, /** @@ -712,7 +731,7 @@

    Source: math/RandomDataGenerator.js

    * @return {any} A random member of the array. */ weightedPick: function (ary) { - return ary[~~(Math.pow(this.frac(), 2) * ary.length)]; + return ary[~~(Math.pow(this.frac(), 2) * (ary.length - 1))]; }, /** @@ -759,7 +778,7 @@

    Source: math/RandomDataGenerator.js

    Documentation generated by JSDoc 3.3.0-dev - on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template. + on Fri Mar 14 2014 06:34:18 GMT-0000 (GMT) using the DocStrap template. @@ -786,6 +805,9 @@

    Source: math/RandomDataGenerator.js

    + + + + + + + + + + + + + + + + + + + diff --git a/docs/StageScaleMode.js.html b/docs/ScaleManager.js.html similarity index 82% rename from docs/StageScaleMode.js.html rename to docs/ScaleManager.js.html index 864ee5f337..031936fa06 100644 --- a/docs/StageScaleMode.js.html +++ b/docs/ScaleManager.js.html @@ -3,7 +3,7 @@ - Phaser Source: system/StageScaleMode.js + Phaser Source: core/ScaleManager.js + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: tilemap/Tile.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2014 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* Create a new `Tile` object.
    +*
    +* @class Phaser.Tile
    +* @classdesc A Tile is a representation of a single tile within the Tilemap.
    +* @constructor
    +* @param {object} layer - The layer in the Tilemap data that this tile belongs to.
    +* @param {number} index - The index of this tile type in the core map data.
    +* @param {number} x - The x coordinate of this tile.
    +* @param {number} y - The y coordinate of this tile.
    +* @param {number} width - Width of the tile.
    +* @param {number} height - Height of the tile.
    +*/
    +Phaser.Tile = function (layer, index, x, y, width, height) {
    +
    +    /**
    +    * @property {object} layer - The layer in the Tilemap data that this tile belongs to.
    +    */
    +    this.layer = layer;
    +
    +    /**
    +    * @property {number} index - The index of this tile within the map data corresponding to the tileset.
    +    */
    +    this.index = index;
    +    
    +    /**
    +    * @property {number} x - The x map coordinate of this tile.
    +    */
    +    this.x = x;
    +    
    +    /**
    +    * @property {number} y - The y map coordinate of this tile.
    +    */
    +    this.y = y;
    +
    +    /**
    +    * @property {number} x - The x map coordinate of this tile.
    +    */
    +    this.worldX = x * width;
    +    
    +    /**
    +    * @property {number} y - The y map coordinate of this tile.
    +    */
    +    this.worldY = y * height;
    +
    +    /**
    +    * @property {number} width - The width of the tile in pixels.
    +    */
    +    this.width = width;
    +    
    +    /**
    +    * @property {number} height - The height of the tile in pixels.
    +    */
    +    this.height = height;
    +
    +    /**
    +    * @property {number} width - The width of the tile in pixels.
    +    */
    +    this.centerX = Math.abs(width / 2);
    +    
    +    /**
    +    * @property {number} height - The height of the tile in pixels.
    +    */
    +    this.centerY = Math.abs(height / 2);
    +
    +    /**
    +    * @property {number} alpha - The alpha value at which this tile is drawn to the canvas.
    +    */
    +    this.alpha = 1;
    +
    +    /**
    +    * @property {object} properties - Tile specific properties.
    +    */
    +    this.properties = {};
    +
    +    /**
    +    * @property {boolean} scanned - Has this tile been walked / turned into a poly?
    +    */
    +    this.scanned = false;
    +
    +    /**
    +    * @property {boolean} faceTop - Is the top of this tile an interesting edge?
    +    */
    +    this.faceTop = false;
    +
    +    /**
    +    * @property {boolean} faceBottom - Is the bottom of this tile an interesting edge?
    +    */
    +    this.faceBottom = false;
    +
    +    /**
    +    * @property {boolean} faceLeft - Is the left of this tile an interesting edge?
    +    */
    +    this.faceLeft = false;
    +
    +    /**
    +    * @property {boolean} faceRight - Is the right of this tile an interesting edge?
    +    */
    +    this.faceRight = false;
    +
    +    /**
    +    * @property {boolean} collideLeft - Indicating collide with any object on the left.
    +    * @default
    +    */
    +    this.collideLeft = false;
    +
    +    /**
    +    * @property {boolean} collideRight - Indicating collide with any object on the right.
    +    * @default
    +    */
    +    this.collideRight = false;
    +
    +    /**
    +    * @property {boolean} collideUp - Indicating collide with any object on the top.
    +    * @default
    +    */
    +    this.collideUp = false;
    +
    +    /**
    +    * @property {boolean} collideDown - Indicating collide with any object on the bottom.
    +    * @default
    +    */
    +    this.collideDown = false;
    +
    +    /**
    +    * @property {function} collisionCallback - Tile collision callback.
    +    * @default
    +    */
    +    this.collisionCallback = null;
    +
    +    /**
    +    * @property {object} collisionCallbackContext - The context in which the collision callback will be called.
    +    * @default
    +    */
    +    this.collisionCallbackContext = this;
    +
    +};
    +
    +Phaser.Tile.prototype = {
    +
    +    /**
    +    * Check if the given x and y world coordinates are within this Tile.
    +    *
    +    * @method Phaser.Tile#containsPoint
    +    * @param {number} x - The x coordinate to test.
    +    * @param {number} y - The y coordinate to test.
    +    * @return {boolean} True if the coordinates are within this Tile, otherwise false.
    +    */
    +    containsPoint: function (x, y) {
    +
    +        return !(x < this.worldX || y < this.worldY || x > this.right || y > this.bottom);
    +
    +    },
    +
    +    /**
    +    * Check for intersection with this tile.
    +    *
    +    * @method Phaser.Tile#intersects
    +    * @param {number} x - The x axis in pixels.
    +    * @param {number} y - The y axis in pixels.
    +    * @param {number} right - The right point.
    +    * @param {number} bottom - The bottom point.
    +    */
    +    intersects: function (x, y, right, bottom) {
    +
    +        if (right <= this.worldX)
    +        {
    +            return false;
    +        }
    +
    +        if (bottom <= this.worldY)
    +        {
    +            return false;
    +        }
    +
    +        if (x >= this.worldX + this.width)
    +        {
    +            return false;
    +        }
    +
    +        if (y >= this.worldY + this.height)
    +        {
    +            return false;
    +        }
    +
    +        return true;
    +
    +    },
    +
    +    /**
    +    * Set a callback to be called when this tile is hit by an object.
    +    * The callback must true true for collision processing to take place.
    +    * 
    +    * @method Phaser.Tile#setCollisionCallback
    +    * @param {function} callback - Callback function.
    +    * @param {object} context - Callback will be called within this context.
    +    */
    +    setCollisionCallback: function (callback, context) {
    +
    +        this.collisionCallback = callback;
    +        this.collisionCallbackContext = context;
    +
    +    },
    +
    +    /**
    +    * Clean up memory.
    +    *
    +    * @method Phaser.Tile#destroy
    +    */
    +    destroy: function () {
    +
    +        this.collisionCallback = null;
    +        this.collisionCallbackContext = null;
    +        this.properties = null;
    +        
    +    },
    +
    +    /**
    +    * Set collision settings on this tile.
    +    *
    +    * @method Phaser.Tile#setCollision
    +    * @param {boolean} left - Indicating collide with any object on the left.
    +    * @param {boolean} right - Indicating collide with any object on the right.
    +    * @param {boolean} up - Indicating collide with any object on the top.
    +    * @param {boolean} down - Indicating collide with any object on the bottom.
    +    */
    +    setCollision: function (left, right, up, down) {
    +
    +        this.collideLeft = left;
    +        this.collideRight = right;
    +        this.collideUp = up;
    +        this.collideDown = down;
    +
    +    },
    +
    +    /**
    +    * Reset collision status flags.
    +    *
    +    * @method Phaser.Tile#resetCollision
    +    */
    +    resetCollision: function () {
    +
    +        this.collideLeft = false;
    +        this.collideRight = false;
    +        this.collideUp = false;
    +        this.collideDown = false;
    +
    +        this.faceTop = false;
    +        this.faceBottom = false;
    +        this.faceLeft = false;
    +        this.faceRight = false;
    +
    +    },
    +
    +    /**
    +    * Is this tile interesting?
    +    *
    +    * @method Phaser.Tile#isInteresting
    +    * @param {boolean} collides - If true will check any collides value.
    +    * @param {boolean} faces - If true will check any face value.
    +    * @return {boolean} True if the Tile is interesting, otherwise false.
    +    */
    +    isInteresting: function (collides, faces) {
    +
    +        if (collides && faces)
    +        {
    +            //  Does this tile have any collide flags OR interesting face?
    +            return (this.collideLeft || this.collideRight || this.collideUp || this.collideDown || this.faceTop || this.faceBottom || this.faceLeft || this.faceRight || this.collisionCallback || this.layer.callbacks[this.index]);
    +        }
    +        else if (collides)
    +        {
    +            //  Does this tile collide?
    +            return (this.collideLeft || this.collideRight || this.collideUp || this.collideDown);
    +        }
    +        else if (faces)
    +        {
    +            //  Does this tile have an interesting face?
    +            return (this.faceTop || this.faceBottom || this.faceLeft || this.faceRight);
    +        }
    +
    +        return false;
    +
    +    },
    +
    +    /**
    +    * Copies the tile data and properties from the given tile to this tile.
    +    *
    +    * @method Phaser.Tile#copy
    +    * @param {Phaser.Tile} tile - The tile to copy from.
    +    */
    +    copy: function (tile) {
    +
    +        this.index = tile.index;
    +        this.alpha = tile.alpha;
    +        this.properties = tile.properties;
    +
    +        this.collideUp = tile.collideUp;
    +        this.collideDown = tile.collideDown;
    +        this.collideLeft = tile.collideLeft;
    +        this.collideRight = tile.collideRight;
    +
    +        this.collisionCallback = tile.collisionCallback;
    +        this.collisionCallbackContext = tile.collisionCallbackContext;
    +
    +    }
    +
    +};
    +
    +Phaser.Tile.prototype.constructor = Phaser.Tile;
    +
    +/**
    +* @name Phaser.Tile#canCollide
    +* @property {boolean} canCollide - True if this tile can collide or has a collision callback.
    +* @readonly
    +*/
    +Object.defineProperty(Phaser.Tile.prototype, "collides", {
    +    
    +    get: function () {
    +        return (this.collideLeft || this.collideRight || this.collideUp || this.collideDown);
    +    }
    +
    +});
    +
    +/**
    +* @name Phaser.Tile#canCollide
    +* @property {boolean} canCollide - True if this tile can collide or has a collision callback.
    +* @readonly
    +*/
    +Object.defineProperty(Phaser.Tile.prototype, "canCollide", {
    +    
    +    get: function () {
    +        return (this.collideLeft || this.collideRight || this.collideUp || this.collideDown || this.collisionCallback || this.layer.callbacks[this.index]);
    +    }
    +
    +});
    +
    +/**
    +* @name Phaser.Tile#left
    +* @property {number} left - The x value in pixels.
    +* @readonly
    +*/
    +Object.defineProperty(Phaser.Tile.prototype, "left", {
    +    
    +    get: function () {
    +        return this.worldX;
    +    }
    +
    +});
    +
    +/**
    +* @name Phaser.Tile#right
    +* @property {number} right - The sum of the x and width properties.
    +* @readonly
    +*/
    +Object.defineProperty(Phaser.Tile.prototype, "right", {
    +    
    +    get: function () {
    +        return this.worldX + this.width;
    +    }
    +
    +});
    +
    +/**
    +* @name Phaser.Tile#top
    +* @property {number} top - The y value.
    +* @readonly
    +*/
    +Object.defineProperty(Phaser.Tile.prototype, "top", {
    +    
    +    get: function () {
    +        return this.worldY;
    +    }
    +
    +});
    +
    +/**
    +* @name Phaser.Tile#bottom
    +* @property {number} bottom - The sum of the y and height properties.
    +* @readonly
    +*/
    +Object.defineProperty(Phaser.Tile.prototype, "bottom", {
    +    
    +    get: function () {
    +        return this.worldY + this.height;
    +    }
    +
    +});
    +
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2014 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Mar 14 2014 06:34:18 GMT-0000 (GMT) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/TileSprite.js.html b/docs/TileSprite.js.html index 78b1b53329..30e107b9b7 100644 --- a/docs/TileSprite.js.html +++ b/docs/TileSprite.js.html @@ -58,10 +58,6 @@ BitmapData -
  • - BitmapFont -
  • -
  • BitmapText
  • @@ -259,35 +255,83 @@
  • - Body + Body +
  • + +
  • + Ninja +
  • + +
  • + AABB +
  • + +
  • + Body +
  • + +
  • + Circle +
  • + +
  • + Tile +
  • + +
  • + P2 +
  • + +
  • + Body +
  • + +
  • + BodyDebug +
  • + +
  • + CollisionGroup +
  • + +
  • + ContactMaterial +
  • + +
  • + DistanceConstraint
  • - CollisionGroup + GearConstraint
  • - ContactMaterial + InversePointProxy
  • - InversePointProxy + LockConstraint
  • - Material + Material
  • - PointProxy + PointProxy
  • - Spring + PrismaticConstraint
  • - World + RevoluteConstraint +
  • + +
  • + Spring
  • @@ -310,6 +354,10 @@ Polygon
  • +
  • + QuadTree +
  • +
  • RandomDataGenerator
  • @@ -326,6 +374,14 @@ RequestAnimationFrame +
  • + RetroFont +
  • + +
  • + ScaleManager +
  • +
  • Signal
  • @@ -354,10 +410,6 @@ Stage -
  • - StageScaleMode -
  • -
  • State
  • @@ -438,40 +490,6 @@ - - @@ -497,7 +515,7 @@

    Source: gameobjects/TileSprite.js

    /** * A TileSprite is a Sprite that has a repeating texture. The texture can be scrolled and scaled and will automatically wrap on the edges as it does so. -* Please note that TileSprites have no input handler or physics bodies. +* Please note that TileSprites, as with normal Sprites, have no input handler or physics bodies by default. Both need enabling. * * @class Phaser.TileSprite * @constructor @@ -535,6 +553,11 @@

    Source: gameobjects/TileSprite.js

    */ this.type = Phaser.TILESPRITE; + /** + * @property {number} z - The z-depth value of this object within its Group (remember the World is a Group as well). No two objects in a Group can have the same z value. + */ + this.z = 0; + /** * @property {Phaser.Events} events - The Events you can subscribe to that are dispatched when certain things happen on this Sprite or its components. */ @@ -589,6 +612,19 @@

    Source: gameobjects/TileSprite.js

    */ this.cameraOffset = new Phaser.Point(); + /** + * By default Sprites won't add themselves to any physics system and their physics body will be `null`. + * To enable them for physics you need to call `game.physics.enable(sprite, system)` where `sprite` is this object + * and `system` is the Physics system you want to use to manage this body. Once enabled you can access all physics related properties via `Sprite.body`. + * + * Important: Enabling a Sprite for P2 or Ninja physics will automatically set `Sprite.anchor` to 0.5 so the physics body is centered on the Sprite. + * If you need a different result then adjust or re-create the Body shape offsets manually, and/or reset the anchor after enabling physics. + * + * @property {Phaser.Physics.Arcade.Body|Phaser.Physics.P2.Body|Phaser.Physics.Ninja.Body|null} body + * @default + */ + this.body = null; + /** * A small internal cache: * 0 = previous position.x @@ -631,6 +667,22 @@

    Source: gameobjects/TileSprite.js

    this.tilePosition.y += this._scroll.y * this.game.time.physicsElapsed; } + if (this.visible) + { + this._cache[3] = this.game.stage.currentRenderOrderID++; + } + + if (this.exists && this.body) + { + this.body.preUpdate(); + } + + // Update any Children + for (var i = 0, len = this.children.length; i < len; i++) + { + this.children[i].preUpdate(); + } + return true; } @@ -653,6 +705,11 @@

    Source: gameobjects/TileSprite.js

    */ Phaser.TileSprite.prototype.postUpdate = function() { + if (this.exists && this.body) + { + this.body.postUpdate(); + } + // Fixed to Camera? if (this._cache[7] === 1) { @@ -660,6 +717,12 @@

    Source: gameobjects/TileSprite.js

    this.position.y = this.game.camera.view.y + this.cameraOffset.y; } + // Update any Children + for (var i = 0, len = this.children.length; i < len; i++) + { + this.children[i].postUpdate(); + } + } /** @@ -767,8 +830,13 @@

    Source: gameobjects/TileSprite.js

    * * @method Phaser.TileSprite#destroy * @memberof Phaser.TileSprite +* @param {boolean} [destroyChildren=true] - Should every child of this object have its destroy method called? */ -Phaser.TileSprite.prototype.destroy = function() { +Phaser.TileSprite.prototype.destroy = function(destroyChildren) { + + if (this.game === null) { return; } + + if (typeof destroyChildren === 'undefined') { destroyChildren = true; } if (this.filters) { @@ -777,7 +845,14 @@

    Source: gameobjects/TileSprite.js

    if (this.parent) { - this.parent.remove(this); + if (this.parent instanceof Phaser.Group) + { + this.parent.remove(this); + } + else + { + this.parent.removeChild(this); + } } this.animations.destroy(); @@ -786,9 +861,19 @@

    Source: gameobjects/TileSprite.js

    var i = this.children.length; - while (i--) + if (destroyChildren) + { + while (i--) + { + this.children[i].destroy(destroyChildren); + } + } + else { - this.removeChild(this.children[i]); + while (i--) + { + this.removeChild(this.children[i]); + } } this.exists = false; @@ -915,6 +1000,53 @@

    Source: gameobjects/TileSprite.js

    }); +/** +* TileSprite.exists controls if the core game loop and physics update this TileSprite or not. +* When you set TileSprite.exists to false it will remove its Body from the physics world (if it has one) and also set TileSprite.visible to false. +* Setting TileSprite.exists to true will re-add the Body to the physics world (if it has a body) and set TileSprite.visible to true. +* +* @name Phaser.TileSprite#exists +* @property {boolean} exists - If the TileSprite is processed by the core game update and physics. +*/ +Object.defineProperty(Phaser.TileSprite.prototype, "exists", { + + get: function () { + + return !!this._cache[6]; + + }, + + set: function (value) { + + if (value) + { + // exists = true + this._cache[6] = 1; + + if (this.body && this.body.type === Phaser.Physics.P2JS) + { + this.body.addToWorld(); + } + + this.visible = true; + } + else + { + // exists = false + this._cache[6] = 0; + + if (this.body && this.body.type === Phaser.Physics.P2JS) + { + this.body.safeRemove = true; + } + + this.visible = false; + + } + } + +}); + /** * By default a TileSprite won't process any input events at all. By setting inputEnabled to true the Phaser.InputHandler is * activated for this object and it will then start to process click/touch events and more. @@ -971,7 +1103,7 @@

    Source: gameobjects/TileSprite.js

    Documentation generated by JSDoc 3.3.0-dev - on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template. + on Fri Mar 14 2014 06:34:18 GMT-0000 (GMT) using the DocStrap template. @@ -998,6 +1130,9 @@

    Source: gameobjects/TileSprite.js

    + + + + + + + + + + + + + + + + + + + diff --git a/docs/World.js___.html b/docs/World.js___.html new file mode 100644 index 0000000000..a462c8bc33 --- /dev/null +++ b/docs/World.js___.html @@ -0,0 +1,783 @@ + + + + + + Phaser Source: core/World.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: core/World.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2014 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* "This world is but a canvas to our imagination." - Henry David Thoreau
    +*
    +* A game has only one world. The world is an abstract place in which all game objects live. It is not bound
    +* by stage limits and can be any size. You look into the world via cameras. All game objects live within
    +* the world at world-based coordinates. By default a world is created the same size as your Stage.
    +*
    +* @class Phaser.World
    +* @extends Phaser.Group
    +* @constructor
    +* @param {Phaser.Game} game - Reference to the current game instance.
    +*/
    +Phaser.World = function (game) {
    +
    +    Phaser.Group.call(this, game, null, '__world', false);
    +
    +    /**
    +    * The World has no fixed size, but it does have a bounds outside of which objects are no longer considered as being "in world" and you should use this to clean-up the display list and purge dead objects.
    +    * By default we set the Bounds to be from 0,0 to Game.width,Game.height. I.e. it will match the size given to the game constructor with 0,0 representing the top-left of the display.
    +    * However 0,0 is actually the center of the world, and if you rotate or scale the world all of that will happen from 0,0.
    +    * So if you want to make a game in which the world itself will rotate you should adjust the bounds so that 0,0 is the center point, i.e. set them to -1000,-1000,2000,2000 for a 2000x2000 sized world centered around 0,0.
    +    * @property {Phaser.Rectangle} bounds - Bound of this world that objects can not escape from.
    +    */
    +    this.bounds = new Phaser.Rectangle(0, 0, game.width, game.height);
    +
    +    /**
    +    * @property {Phaser.Camera} camera - Camera instance.
    +    */
    +    this.camera = null;
    +    
    +}
    +
    +Phaser.World.prototype = Object.create(Phaser.Group.prototype);
    +Phaser.World.prototype.constructor = Phaser.World;
    +
    +/**
    +* Initialises the game world.
    +*
    +* @method Phaser.World#boot
    +* @protected
    +*/
    +Phaser.World.prototype.boot = function () {
    +
    +    this.camera = new Phaser.Camera(this.game, 0, 0, 0, this.game.width, this.game.height);
    +
    +    this.camera.displayObject = this;
    +
    +    this.camera.scale = this.scale;
    +
    +    this.game.camera = this.camera;
    +
    +    this.game.stage.addChild(this);
    +
    +}
    +
    +/**
    +* Updates the size of this world. Note that this doesn't modify the world x/y coordinates, just the width and height.
    +*
    +* @method Phaser.World#setBounds
    +* @param {number} x - Top left most corner of the world.
    +* @param {number} y - Top left most corner of the world.
    +* @param {number} width - New width of the world. Can never be smaller than the Game.width.
    +* @param {number} height - New height of the world. Can never be smaller than the Game.height.
    +*/
    +Phaser.World.prototype.setBounds = function (x, y, width, height) {
    +
    +    if (width < this.game.width)
    +    {
    +        width = this.game.width;
    +    }
    +
    +    if (height < this.game.height)
    +    {
    +        height = this.game.height;
    +    }
    +
    +    this.bounds.setTo(x, y, width, height);
    +
    +    if (this.camera.bounds)
    +    {
    +        //  The Camera can never be smaller than the game size
    +        this.camera.bounds.setTo(x, y, width, height);
    +    }
    +
    +    this.game.physics.setBoundsToWorld();
    +
    +}
    +
    +/**
    +* Destroyer of worlds.
    +* @method Phaser.World#destroy
    +*/
    +Phaser.World.prototype.destroy = function () {
    +
    +    this.camera.reset();
    +
    +    this.game.input.reset(true);
    +
    +    this.removeAll();
    +
    +}
    +
    +/**
    +* @name Phaser.World#width
    +* @property {number} width - Gets or sets the current width of the game world.
    +*/
    +Object.defineProperty(Phaser.World.prototype, "width", {
    +
    +    get: function () {
    +        return this.bounds.width;
    +    },
    +
    +    set: function (value) {
    +        this.bounds.width = value;
    +    }
    +
    +});
    +
    +/**
    +* @name Phaser.World#height
    +* @property {number} height - Gets or sets the current height of the game world.
    +*/
    +Object.defineProperty(Phaser.World.prototype, "height", {
    +
    +    get: function () {
    +        return this.bounds.height;
    +    },
    +
    +    set: function (value) {
    +        this.bounds.height = value;
    +    }
    +
    +});
    +
    +/**
    +* @name Phaser.World#centerX
    +* @property {number} centerX - Gets the X position corresponding to the center point of the world.
    +* @readonly
    +*/
    +Object.defineProperty(Phaser.World.prototype, "centerX", {
    +
    +    get: function () {
    +        return this.bounds.halfWidth;
    +    }
    +
    +});
    +
    +/**
    +* @name Phaser.World#centerY
    +* @property {number} centerY - Gets the Y position corresponding to the center point of the world.
    +* @readonly
    +*/
    +Object.defineProperty(Phaser.World.prototype, "centerY", {
    +
    +    get: function () {
    +        return this.bounds.halfHeight;
    +    }
    +
    +});
    +
    +/**
    +* @name Phaser.World#randomX
    +* @property {number} randomX - Gets a random integer which is lesser than or equal to the current width of the game world.
    +* @readonly
    +*/
    +Object.defineProperty(Phaser.World.prototype, "randomX", {
    +
    +    get: function () {
    +
    +        if (this.bounds.x < 0)
    +        {
    +            return this.game.rnd.integerInRange(this.bounds.x, (this.bounds.width - Math.abs(this.bounds.x)));
    +        }
    +        else
    +        {
    +            return this.game.rnd.integerInRange(this.bounds.x, this.bounds.width);
    +        }
    +
    +    }
    +
    +});
    +
    +/**
    +* @name Phaser.World#randomY
    +* @property {number} randomY - Gets a random integer which is lesser than or equal to the current height of the game world.
    +* @readonly
    +*/
    +Object.defineProperty(Phaser.World.prototype, "randomY", {
    +
    +    get: function () {
    +
    +        if (this.bounds.y < 0)
    +        {
    +            return this.game.rnd.integerInRange(this.bounds.y, (this.bounds.height - Math.abs(this.bounds.y)));
    +        }
    +        else
    +        {
    +            return this.game.rnd.integerInRange(this.bounds.y, this.bounds.height);
    +        }
    +
    +    }
    +
    +});
    +
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2014 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Mar 14 2014 06:34:18 GMT-0000 (GMT) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/build/conf.json b/docs/build/conf.json index 7ef6be69c8..67c45188d6 100644 --- a/docs/build/conf.json +++ b/docs/build/conf.json @@ -22,7 +22,9 @@ "../../src/tween/", "../../src/utils/" ], - "exclude": [], + "exclude": [ + "../../src/physics/p2/p2.js" + ], "includePattern": ".+\\.js(doc)?$", "excludePattern": "(^|\\/|\\\\)_" }, diff --git a/docs/classes.list.html b/docs/classes.list.html index e9893460f2..f272dc12f5 100644 --- a/docs/classes.list.html +++ b/docs/classes.list.html @@ -58,10 +58,6 @@ BitmapData -
  • - BitmapFont -
  • -
  • BitmapText
  • @@ -259,35 +255,83 @@
  • - Body + Body +
  • + +
  • + Ninja +
  • + +
  • + AABB +
  • + +
  • + Body +
  • + +
  • + Circle
  • - CollisionGroup + Tile
  • - ContactMaterial + P2
  • - InversePointProxy + Body
  • - Material + BodyDebug
  • - PointProxy + CollisionGroup
  • - Spring + ContactMaterial
  • - World + DistanceConstraint +
  • + +
  • + GearConstraint +
  • + +
  • + InversePointProxy +
  • + +
  • + LockConstraint +
  • + +
  • + Material +
  • + +
  • + PointProxy +
  • + +
  • + PrismaticConstraint +
  • + +
  • + RevoluteConstraint +
  • + +
  • + Spring
  • @@ -310,6 +354,10 @@ Polygon
  • +
  • + QuadTree +
  • +
  • RandomDataGenerator
  • @@ -326,6 +374,14 @@ RequestAnimationFrame +
  • + RetroFont +
  • + +
  • + ScaleManager +
  • +
  • Signal
  • @@ -354,10 +410,6 @@ Stage -
  • - StageScaleMode -
  • -
  • State
  • @@ -438,40 +490,6 @@ - - @@ -558,9 +576,6 @@

    Classes

    BitmapData
    -
    BitmapFont
    -
    -
    BitmapText
    @@ -705,34 +720,67 @@

    Classes

    Physics
    -
    Physics
    +
    Arcade
    -
    Arcade
    +
    Body
    +
    + +
    Ninja
    -
    Body
    +
    AABB
    -
    CollisionGroup
    +
    Body
    -
    ContactMaterial
    +
    Circle
    -
    InversePointProxy
    +
    Tile
    -
    Material
    +
    P2
    -
    PointProxy
    +
    Body
    -
    Spring
    +
    BodyDebug
    -
    World
    +
    CollisionGroup
    +
    + +
    ContactMaterial
    +
    + +
    DistanceConstraint
    +
    + +
    GearConstraint
    +
    + +
    InversePointProxy
    +
    + +
    LockConstraint
    +
    + +
    Material
    +
    + +
    PointProxy
    +
    + +
    PrismaticConstraint
    +
    + +
    RevoluteConstraint
    +
    + +
    Spring
    Plugin
    @@ -750,6 +798,9 @@

    Classes

    Polygon
    +
    QuadTree
    +
    +
    RandomDataGenerator
    @@ -762,6 +813,12 @@

    Classes

    RequestAnimationFrame
    +
    RetroFont
    +
    + +
    ScaleManager
    +
    +
    Signal
    @@ -783,9 +840,6 @@

    Classes

    Stage
    -
    StageScaleMode
    -
    -
    State
    @@ -881,7 +935,7 @@

    Namespaces

    Documentation generated by JSDoc 3.3.0-dev - on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template. + on Fri Mar 14 2014 06:34:18 GMT-0000 (GMT) using the DocStrap template. @@ -912,6 +966,9 @@

    Namespaces