diff --git a/v3/src/physics/impact/Body.js b/v3/src/physics/impact/Body.js index d22ffde9b..8b66df83e 100644 --- a/v3/src/physics/impact/Body.js +++ b/v3/src/physics/impact/Body.js @@ -1,7 +1,6 @@ // Phaser.Physics.Impact.Body var Class = require('../../utils/Class'); -var Components = require('./Components'); var COLLIDES = require('./COLLIDES'); var GetVelocity = require('./GetVelocity'); var TYPE = require('./TYPE'); @@ -29,6 +28,8 @@ var Body = new Class({ this.parent; + this.id = world.getNextID(); + this.name = ''; this.size = { x: sx, y: sy }; diff --git a/v3/src/physics/impact/CollisionMap.js b/v3/src/physics/impact/CollisionMap.js index 50fa86387..989f04956 100644 --- a/v3/src/physics/impact/CollisionMap.js +++ b/v3/src/physics/impact/CollisionMap.js @@ -26,15 +26,12 @@ var CollisionMap = new Class({ // Set up the trace-result var res = { collision: { x: false, y: false, slope: false }, - pos: { x: x, y: y }, + pos: { x: x + vx, y: y + vy }, tile: { x: 0, y: 0 } }; if (!this.data) { - res.pos.x += vx; - res.pos.y += vy; - return res; } @@ -80,13 +77,13 @@ var CollisionMap = new Class({ step: function (res, x, y, vx, vy, width, height, rvx, rvy, step) { - res.pos.x += vx; - res.pos.y += vy; + // res.pos.x += vx; + // res.pos.y += vy; - if (window.dumpit) - { - console.log('STEP', res.pos.x, res.pos.y, 'VX', vx, 'VY', vy, 'step', step); - } + // if (window.dumpit) + // { + // console.log('STEP', res.pos.x, res.pos.y, 'VX', vx, 'VY', vy, 'step', step); + // } var t = 0; var tilesize = this.tilesize; @@ -144,10 +141,10 @@ var CollisionMap = new Class({ t = this.data[tileY][tileX]; - if (window.debugslopes) - { - console.log('Tile at', tileX, 'x', tileY, '=', t); - } + // if (window.debugslopes) + // { + // console.log('Tile at', tileX, 'x', tileY, '=', t); + // } if (t === 1 || t > this.lastSlope || (t > 1 && this.checkDef(res, t, x, y, rvx, rvy, width, height, tileX, tileY))) { diff --git a/v3/src/physics/impact/World.js b/v3/src/physics/impact/World.js index d8780bd28..fc6f7a2ad 100644 --- a/v3/src/physics/impact/World.js +++ b/v3/src/physics/impact/World.js @@ -29,6 +29,13 @@ var World = new Class({ this.collisionMap = new CollisionMap(); this.delta = 0; + + this._lastId = 0; + }, + + getNextID: function () + { + return this._lastId++; }, create: function (x, y, sizeX, sizeY) @@ -55,6 +62,7 @@ var World = new Class({ // Update all bodies var i; + var body; var bodies = this.bodies.entries; var len = bodies.length; var hash = {}; @@ -64,7 +72,7 @@ var World = new Class({ for (i = 0; i < len; i++) { - var body = bodies[i]; + body = bodies[i]; if (body.enabled) { @@ -76,13 +84,9 @@ var World = new Class({ for (i = 0; i < len; i++) { - var body = bodies[i]; + body = bodies[i]; - if (body.skipHash()) - { - continue; - } - else + if (!body.skipHash()) { this.checkHash(body, hash, size); } @@ -147,7 +151,6 @@ var World = new Class({ if (bodyA.collides && bodyB.collides && bodyA.collides + bodyB.collides > COLLIDES.ACTIVE) { - // console.log('solve'); Solver(this, bodyA, bodyB); } },