mirror of
https://github.com/wassname/phaser.git
synced 2026-09-12 12:40:47 +08:00
Removed input handler from Graphics as it's just meant to be used as a texture really, if you need input events you can apply Graphics to a Sprite.
You can now create a Physics Body directly via game.physics.createBody(), and Body has been updated so it's no longer always bound to a Sprite. Debug.renderPhysicsBody now works with Rectangles, Lines and multiple Convex shapes. Starting to get the Tiled polyline parsing working nicely. Not too far off a complete tilemap collision.
This commit is contained in:
@@ -232,3 +232,37 @@ Phaser.Physics.World.prototype.destroy = function () {
|
||||
this.game = null;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* @method Phaser.Physics.World.prototype.createBody
|
||||
* @param {number} x - The x coordinate of Body.
|
||||
* @param {number} y - The y coordinate of Body.
|
||||
* @param {number} mass - The mass of the Body. A mass of 0 means a 'static' Body is created.
|
||||
* @param {boolean} [addToWorld=false] - Automatically add this Body to the world? (usually false as it won't have any shapes on construction).
|
||||
* @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.
|
||||
*/
|
||||
Phaser.Physics.World.prototype.createBody = function (x, y, mass, addToWorld, options, data) {
|
||||
|
||||
if (typeof addToWorld === 'undefined') { addToWorld = false; }
|
||||
|
||||
var body = new Phaser.Physics.Body(this.game, null, x, y, mass);
|
||||
|
||||
if (data)
|
||||
{
|
||||
body.addPolygon(options, data);
|
||||
}
|
||||
|
||||
if (addToWorld)
|
||||
{
|
||||
this.addBody(body.data);
|
||||
}
|
||||
|
||||
return body;
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user