Skip to content

Commit a74feee

Browse files
committed
Use local var
1 parent 54612b5 commit a74feee

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

src/physics/arcade/World.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,12 +1164,14 @@ var World = new Class({
11641164
*/
11651165
computeVelocity: function (body, delta)
11661166
{
1167-
var velocityX = body.velocity.x;
1167+
var velocity = body.velocity;
1168+
1169+
var velocityX = velocity.x;
11681170
var accelerationX = body.acceleration.x;
11691171
var dragX = body.drag.x;
11701172
var maxX = body.maxVelocity.x;
11711173

1172-
var velocityY = body.velocity.y;
1174+
var velocityY = velocity.y;
11731175
var accelerationY = body.acceleration.y;
11741176
var dragY = body.drag.y;
11751177
var maxY = body.maxVelocity.y;
@@ -1257,12 +1259,12 @@ var World = new Class({
12571259
}
12581260
}
12591261

1260-
body.velocity.x = Clamp(velocityX, -maxX, maxX);
1261-
body.velocity.y = Clamp(velocityY, -maxY, maxY);
1262+
velocity.x = Clamp(velocityX, -maxX, maxX);
1263+
velocity.y = Clamp(velocityY, -maxY, maxY);
12621264

1263-
if (maxSpeed > -1 && body.velocity.length() > maxSpeed)
1265+
if (maxSpeed > -1 && velocity.length() > maxSpeed)
12641266
{
1265-
body.velocity.normalize().scale(maxSpeed);
1267+
velocity.normalize().scale(maxSpeed);
12661268
}
12671269
},
12681270

0 commit comments

Comments
 (0)