Skip to content

Commit 22b1ce9

Browse files
committed
Added Phasers new Physics Manager and restored the pre-1.1.4 ArcadePhysics system. The new manager can handle multiple physics systems running in parallel, which could be extremely useful for lots of games.
1 parent cc82336 commit 22b1ce9

26 files changed

Lines changed: 4004 additions & 908 deletions

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ Bug Fixes:
214214
* You can now load in CSV Tilemaps again and they get created properly (fixes #391)
215215
* Tilemap.putTile can now insert a tile into a null/blank area of the map (before it could only replace existing tiles)
216216
* Tilemap.putTile now correctly re-calculates the collision data based on the new collideIndexes array (fixes #371)
217+
* Circle.circumferencePoint using the asDegrees parameter would apply degToRad instead of radToDeg (thanks Ziriax, fixes #509)
217218

218219

219220
TO DO:

build/config.php

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,20 @@
135135
<script src="$path/src/utils/Debug.js"></script>
136136
<script src="$path/src/utils/Color.js"></script>
137137
138-
<script src="$path/src/physics/World.js"></script>
139-
<script src="$path/src/physics/PointProxy.js"></script>
140-
<script src="$path/src/physics/InversePointProxy.js"></script>
141-
<script src="$path/src/physics/Body.js"></script>
142-
<script src="$path/src/physics/Spring.js"></script>
143-
<script src="$path/src/physics/Material.js"></script>
144-
<script src="$path/src/physics/ContactMaterial.js"></script>
145-
<script src="$path/src/physics/CollisionGroup.js"></script>
138+
<script src="$path/src/physics/Physics.js"></script>
139+
140+
<script src="$path/src/physics/arcade/World.js"></script>
141+
<script src="$path/src/physics/arcade/Body.js"></script>
142+
<script src="$path/src/physics/arcade/QuadTree.js"></script>
143+
144+
<script src="$path/src/physics/p2/World.js"></script>
145+
<script src="$path/src/physics/p2/PointProxy.js"></script>
146+
<script src="$path/src/physics/p2/InversePointProxy.js"></script>
147+
<script src="$path/src/physics/p2/Body.js"></script>
148+
<script src="$path/src/physics/p2/Spring.js"></script>
149+
<script src="$path/src/physics/p2/Material.js"></script>
150+
<script src="$path/src/physics/p2/ContactMaterial.js"></script>
151+
<script src="$path/src/physics/p2/CollisionGroup.js"></script>
146152
147153
<script src="$path/src/particles/Particles.js"></script>
148154
<script src="$path/src/particles/arcade/ArcadeParticles.js"></script>
@@ -154,4 +160,12 @@
154160
<script src="$path/src/tilemap/TilemapParser.js"></script>
155161
<script src="$path/src/tilemap/Tileset.js"></script>
156162
EOL;
163+
164+
/*
165+
166+
167+
168+
169+
*/
170+
157171
?>

build/phaser.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1450,7 +1450,7 @@ declare module Phaser {
14501450
static intersectsRectangle(c: Phaser.Circle, r: Phaser.Rectangle): boolean;
14511451
//methods
14521452
circumference(): number;
1453-
circumferencePoint(angle: number, asDegrees: number, output?: Phaser.Point): Phaser.Point;
1453+
circumferencePoint(angle: number, asDegrees: boolean, output?: Phaser.Point): Phaser.Point;
14541454
clone(out: Phaser.Circle): Phaser.Circle;
14551455
contains(x: number, y: number): boolean;
14561456
copyFrom(source: any): Circle;

examples/wip/physics-1.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
2+
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render });
3+
4+
function preload() {
5+
6+
game.load.image('atari', 'assets/sprites/atari130xe.png');
7+
game.load.image('mushroom', 'assets/sprites/mushroom2.png');
8+
9+
}
10+
11+
var sprite1;
12+
var sprite2;
13+
14+
function create() {
15+
16+
game.stage.backgroundColor = '#2d2d2d';
17+
18+
// This will check Sprite vs. Sprite collision
19+
20+
sprite1 = game.add.sprite(50, 200, 'atari');
21+
sprite1.name = 'atari';
22+
23+
sprite2 = game.add.sprite(700, 220, 'mushroom');
24+
sprite2.name = 'mushroom';
25+
26+
// Enable the physics bodies of both sprites
27+
game.physics.enable([sprite1, sprite2]);
28+
29+
// And move 'em
30+
sprite1.body.velocity.x = 100;
31+
sprite2.body.velocity.x = -100;
32+
33+
}
34+
35+
function update() {
36+
37+
// object1, object2, collideCallback, processCallback, callbackContext
38+
game.physics.arcade.collide(sprite1, sprite2, collisionHandler, null, this);
39+
40+
}
41+
42+
function collisionHandler (obj1, obj2) {
43+
44+
// The two sprites are colliding
45+
game.stage.backgroundColor = '#992d2d';
46+
47+
}
48+
49+
function render() {
50+
51+
// game.debug.physicsBody(sprite1.body);
52+
// game.debug.physicsBody(sprite2.body);
53+
54+
}

src/animation/Animation.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,6 @@ Phaser.Animation = function (game, parent, name, frameData, frames, delay, loop)
139139
// Set-up some event listeners
140140
this.game.onPause.add(this.onPause, this);
141141
this.game.onResume.add(this.onResume, this);
142-
143-
console.log('animation created', this);
144142

145143
};
146144

src/core/Game.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ Phaser.Game = function (width, height, renderer, parent, state, transparent, ant
172172
this.world = null;
173173

174174
/**
175-
* @property {Phaser.Physics.World} physics - Reference to the physics world.
175+
* @property {Phaser.Physics} physics - Reference to the physics manager.
176176
*/
177177
this.physics = null;
178178

@@ -414,7 +414,7 @@ Phaser.Game.prototype = {
414414
this.tweens = new Phaser.TweenManager(this);
415415
this.input = new Phaser.Input(this);
416416
this.sound = new Phaser.SoundManager(this);
417-
this.physics = new Phaser.Physics.World(this, this.physicsConfig);
417+
this.physics = new Phaser.Physics(this, this.physicsConfig);
418418
this.particles = new Phaser.Particles(this);
419419
this.plugins = new Phaser.PluginManager(this, this);
420420
this.net = new Phaser.Net(this);

0 commit comments

Comments
 (0)