mirror of
https://github.com/wassname/phaser.git
synced 2026-07-16 01:20:13 +08:00
Tilemap.createCollisionObjects will parse Tiled data for objectgroups and convert polyline instances into physics objects you can collide with in the world.
After defining tiles that collide on a Tilemap, you need to call Tilemap.generateCollisionData(layer) to populate the physics world with the data required. Debug.renderPhysicsBody updated to take camera location and body rotation into account. Body movement functions put back to velocity :) Updated to latest dev version of pixi and latest p2.js Updated docs
This commit is contained in:
+138
-19
@@ -58,6 +58,10 @@
|
||||
<a href="Phaser.BitmapData.html">BitmapData</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.BitmapFont.html">BitmapFont</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.BitmapText.html">BitmapText</a>
|
||||
</li>
|
||||
@@ -90,10 +94,6 @@
|
||||
<a href="Phaser.Device.html">Device</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.DOMSprite.html">DOMSprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.html">Easing</a>
|
||||
</li>
|
||||
@@ -142,6 +142,10 @@
|
||||
<a href="Phaser.Easing.Sinusoidal.html">Sinusoidal</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Ellipse.html">Ellipse</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Events.html">Events</a>
|
||||
</li>
|
||||
@@ -250,10 +254,6 @@
|
||||
<a href="Phaser.Physics.Arcade.html">Arcade</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.Arcade.Body.html">Body</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Plugin.html">Plugin</a>
|
||||
</li>
|
||||
@@ -314,6 +314,10 @@
|
||||
<a href="Phaser.Sprite.html">Sprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.SpriteBatch.html">SpriteBatch</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Stage.html">Stage</a>
|
||||
</li>
|
||||
@@ -412,6 +416,10 @@
|
||||
<a href="global.html#canUseNewCanvasBlendModes">canUseNewCanvasBlendModes</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="global.html#getBounds">getBounds</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="global.html#getNextPowerOfTwo">getNextPowerOfTwo</a>
|
||||
</li>
|
||||
@@ -458,14 +466,14 @@
|
||||
/**
|
||||
* Phaser Group constructor.
|
||||
* @class Phaser.Group
|
||||
* @classdesc A Group is a container for display objects that allows for fast pooling, recycling and collision checks.
|
||||
* @classdesc A Group is a container for display objects that allows for fast pooling and object recycling. Groups can be nested within other Groups and have their own local transforms.
|
||||
* @constructor
|
||||
* @param {Phaser.Game} game - A reference to the currently running game.
|
||||
* @param {*} parent - The parent Group, DisplayObject or DisplayObjectContainer that this Group will be added to. If undefined or null it will use game.world.
|
||||
* @param {Phaser.Group|Phaser.Sprite} parent - The parent Group, DisplayObject or DisplayObjectContainer that this Group will be added to. If undefined or null it will use game.world.
|
||||
* @param {string} [name=group] - A name for this Group. Not used internally but useful for debugging.
|
||||
* @param {boolean} [useStage=false] - Should this Group be added to the World (default, false) or direct to the Stage (true).
|
||||
* @param {boolean} [addToStage=false] - If set to true this Group will be added directly to the Game.Stage instead of Game.World.
|
||||
*/
|
||||
Phaser.Group = function (game, parent, name, useStage) {
|
||||
Phaser.Group = function (game, parent, name, addToStage) {
|
||||
|
||||
/**
|
||||
* @property {Phaser.Game} game - A reference to the currently running Game.
|
||||
@@ -484,7 +492,7 @@ Phaser.Group = function (game, parent, name, useStage) {
|
||||
|
||||
PIXI.DisplayObjectContainer.call(this);
|
||||
|
||||
if (typeof useStage === 'undefined')
|
||||
if (typeof addToStage === 'undefined' || addToStage === false)
|
||||
{
|
||||
if (parent)
|
||||
{
|
||||
@@ -492,12 +500,12 @@ Phaser.Group = function (game, parent, name, useStage) {
|
||||
}
|
||||
else
|
||||
{
|
||||
this.game.stage._stage.addChild(this);
|
||||
this.game.stage.addChild(this);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.game.stage._stage.addChild(this);
|
||||
this.game.stage.addChild(this);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -521,7 +529,6 @@ Phaser.Group = function (game, parent, name, useStage) {
|
||||
/**
|
||||
* @property {Phaser.Group|Phaser.Sprite} parent - The parent of this Group.
|
||||
*/
|
||||
// this.group = null;
|
||||
|
||||
/**
|
||||
* @property {Phaser.Point} scale - The scale of the Group container.
|
||||
@@ -541,6 +548,26 @@ Phaser.Group = function (game, parent, name, useStage) {
|
||||
|
||||
this._cursorIndex = 0;
|
||||
|
||||
/**
|
||||
* @property {Phaser.Point} cameraOffset - If this object is fixedToCamera then this stores the x/y offset that its drawn at, from the top-left of the camera view.
|
||||
*/
|
||||
this.cameraOffset = new Phaser.Point();
|
||||
|
||||
/**
|
||||
* A small internal cache:
|
||||
* 0 = previous position.x
|
||||
* 1 = previous position.y
|
||||
* 2 = previous rotation
|
||||
* 3 = renderID
|
||||
* 4 = fresh? (0 = no, 1 = yes)
|
||||
* 5 = outOfBoundsFired (0 = no, 1 = yes)
|
||||
* 6 = exists (0 = no, 1 = yes)
|
||||
* 7 = fixed to camera (0 = no, 1 = yes)
|
||||
* @property {Int16Array} _cache
|
||||
* @private
|
||||
*/
|
||||
this._cache = new Int16Array([0, 0, 0, 0, 1, 0, 1, 0]);
|
||||
|
||||
};
|
||||
|
||||
Phaser.Group.prototype = Object.create(PIXI.DisplayObjectContainer.prototype);
|
||||
@@ -576,8 +603,6 @@ Phaser.Group.SORT_ASCENDING = -1;
|
||||
*/
|
||||
Phaser.Group.SORT_DESCENDING = 1;
|
||||
|
||||
// PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
|
||||
|
||||
/**
|
||||
* Adds an existing object to this Group. The object can be an instance of Phaser.Sprite, Phaser.Button or any other display object.
|
||||
* The child is automatically added to the top of the Group, so renders on-top of everything else within the Group. If you need to control
|
||||
@@ -1155,6 +1180,69 @@ Phaser.Group.prototype.callAll = function (method, context) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The core preUpdate - as called by World.
|
||||
* @method Phaser.Group#preUpdate
|
||||
* @protected
|
||||
*/
|
||||
Phaser.Group.prototype.preUpdate = function () {
|
||||
|
||||
if (!this.exists || !this.parent.exists)
|
||||
{
|
||||
this.renderOrderID = -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
var i = this.children.length;
|
||||
|
||||
while (i--)
|
||||
{
|
||||
this.children[i].preUpdate();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The core update - as called by World.
|
||||
* @method Phaser.Group#update
|
||||
* @protected
|
||||
*/
|
||||
Phaser.Group.prototype.update = function () {
|
||||
|
||||
var i = this.children.length;
|
||||
|
||||
while (i--)
|
||||
{
|
||||
this.children[i].update();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The core postUpdate - as called by World.
|
||||
* @method Phaser.Group#postUpdate
|
||||
* @protected
|
||||
*/
|
||||
Phaser.Group.prototype.postUpdate = function () {
|
||||
|
||||
// Fixed to Camera?
|
||||
if (this._cache[7] === 1)
|
||||
{
|
||||
this.x = this.game.camera.view.x + this.cameraOffset.x;
|
||||
this.y = this.game.camera.view.y + this.cameraOffset.y;
|
||||
}
|
||||
|
||||
var i = this.children.length;
|
||||
|
||||
while (i--)
|
||||
{
|
||||
this.children[i].postUpdate();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows you to call your own function on each member of this Group. You must pass the callback and context in which it will run.
|
||||
* After the checkExists parameter you can add as many parameters as you like, which will all be passed to the callback along with the child.
|
||||
@@ -1589,6 +1677,37 @@ Object.defineProperty(Phaser.Group.prototype, "angle", {
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* A Group that is fixed to the camera uses its x/y coordinates as offsets from the top left of the camera. These are stored in Group.cameraOffset.
|
||||
* Note that the cameraOffset values are in addition to any parent in the display list.
|
||||
* So if this Group was in a Group that has x: 200, then this will be added to the cameraOffset.x
|
||||
*
|
||||
* @name Phaser.Group#fixedToCamera
|
||||
* @property {boolean} fixedToCamera - Set to true to fix this Group to the Camera at its current world coordinates.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Group.prototype, "fixedToCamera", {
|
||||
|
||||
get: function () {
|
||||
|
||||
return !!this._cache[7];
|
||||
|
||||
},
|
||||
|
||||
set: function (value) {
|
||||
|
||||
if (value)
|
||||
{
|
||||
this._cache[7] = 1;
|
||||
this.cameraOffset.set(this.x, this.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._cache[7] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// Documentation stubs
|
||||
|
||||
/**
|
||||
@@ -1642,7 +1761,7 @@ Object.defineProperty(Phaser.Group.prototype, "angle", {
|
||||
|
||||
<span class="jsdoc-message">
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-dev</a>
|
||||
on Sat Feb 08 2014 07:19:40 GMT-0000 (GMT) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
|
||||
on Tue Feb 18 2014 03:01:17 GMT-0000 (GMT) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
|
||||
</span>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user