Removed Time delta cap, removed drag references from Emitter and tested doing a custom polygon collision.

This commit is contained in:
photonstorm 2014-01-24 03:53:11 +00:00
parent ea9e22f472
commit e3aaec8ac0
6 changed files with 338 additions and 653 deletions

120
examples/wip/land.js Normal file
View file

@ -0,0 +1,120 @@
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render });
function preload() {
game.load.spritesheet('gameboy', 'assets/sprites/gameboy_seize_color_40x60.png', 40, 60);
}
var sprite;
var sprite2;
var land;
function create() {
game.stage.backgroundColor = '#124184';
game.physics.gravity.y = 100;
sprite = game.add.sprite(200, 200, 'gameboy', 0);
sprite.name = 'red';
sprite.body.collideWorldBounds = true;
sprite.body.bounce.setTo(0.9, 0.9);
// sprite2 = game.add.sprite(500, 200, 'gameboy', 2);
// sprite2.name = 'green';
// sprite2.body.collideWorldBounds = true;
// sprite2.body.bounce.setTo(0.9, 0.9);
land = game.add.sprite(10, 490);
land.name = 'land';
land.body.immovable = true;
land.body.allowGravity = false;
land.body.setSize(780, 100, 0, 0);
land.body.polygons = new SAT.Polygon(new SAT.Vector(10, 490), [
new SAT.Vector(),
new SAT.Vector(100,0),
new SAT.Vector(200,50),
new SAT.Vector(400,20),
new SAT.Vector(780,0),
new SAT.Vector(780,100),
new SAT.Vector(0,100),
]);
console.log(land);
game.input.onDown.add(launch, this);
}
function launch() {
sprite.body.velocity.x = -300;
sprite.body.velocity.y = -300;
sprite2.body.velocity.x = 200;
sprite2.body.velocity.y = -200;
}
/*
Tweening body scale test!
sprite = game.add.sprite(300, 300, 'gameboy', 0);
sprite.name = 'red';
sprite.body.collideWorldBounds = true;
// sprite.body.checkCollision.right = false;
sprite.body.bounce.setTo(1, 1);
sprite.body.friction = 0;
// sprite.scale.setTo(2, 2);
sprite2 = game.add.sprite(500, 300, 'gameboy', 2);
sprite2.name = 'green';
sprite2.body.collideWorldBounds = true;
sprite2.body.bounce.setTo(1, 1);
sprite2.body.friction = 0;
game.add.tween(sprite.scale).to({x: 3, y: 3}, 2000, Phaser.Easing.Linear.None, true, 0, 1000, true);
// to: function (properties, duration, ease, autoStart, delay, repeat, yoyo) {
*/
function update() {
// game.physics.collide(sprite, land);
if (sprite.body.overlap(land.body))
{
console.log('o', sprite.body.response);
sprite.body.separate(land.body);
}
// game.physics.collide(sprite, sprite2);
// game.physics.collide(sprite2, land);
}
function render() {
game.debug.renderPolygon(land.body.polygons);
if (sprite)
{
game.debug.renderBodyInfo(sprite, 16, 24);
}
if (sprite)
{
game.debug.renderPolygon(sprite.body.polygons);
}
if (sprite2)
{
game.debug.renderPolygon(sprite2.body.polygons);
}
game.debug.renderRectangle(land.body);
}

View file

@ -16,9 +16,9 @@ function create() {
game.stage.backgroundColor = '#124184';
// game.physics.gravity.y = 100;
game.physics.gravity.y = 100;
sprite = game.add.sprite(0, 300, 'gameboy', 0);
sprite = game.add.sprite(200, 300, 'gameboy', 0);
sprite.name = 'red';
sprite.body.collideWorldBounds = true;
// sprite.body.checkCollision.right = false;
@ -26,12 +26,14 @@ function create() {
// sprite.body.bounce.setTo(1, 1);
// sprite.body.friction = 0;
// sprite.scale.setTo(2, 2);
sprite.body.mass = 2;
// sprite2 = game.add.sprite(500, 300, 'gameboy', 2);
sprite2 = game.add.sprite(500, 300, 'gameboy', 2);
sprite2.name = 'green';
sprite2.body.collideWorldBounds = true;
sprite2.body.bounce.setTo(0.9, 0.9);
sprite2.body.mass = 1;
// sprite2.body.bounce.setTo(1, 1);
// sprite2.body.friction = 0;
@ -64,11 +66,10 @@ function create() {
function launch() {
// sprite.body.velocity.x = 150;
// sprite.body.velocity.x = -400;
// sprite.body.velocity.y = -400;
sprite2.body.velocity.x = -100;
sprite2.body.velocity.y = -100;
sprite.body.velocity.x = -300;
sprite.body.velocity.y = -300;
sprite2.body.velocity.x = 200;
sprite2.body.velocity.y = -200;
}

View file

@ -101,7 +101,7 @@ Phaser.QuadTree.prototype = {
*/
populateHandler: function (sprite) {
if (sprite.body && sprite.body.allowCollision.none === false && sprite.alive)
if (sprite.body && sprite.body.checkCollision.none === false && sprite.alive)
{
this.insert(sprite.body);
}

View file

@ -322,12 +322,12 @@ Phaser.Particles.Arcade.Emitter.prototype.makeParticles = function (keys, frames
if (collide > 0)
{
particle.body.allowCollision.any = true;
particle.body.allowCollision.none = false;
particle.body.checkCollision.any = true;
particle.body.checkCollision.none = false;
}
else
{
particle.body.allowCollision.none = true;
particle.body.checkCollision.none = true;
}
particle.body.collideWorldBounds = collideWorldBounds;

File diff suppressed because it is too large Load diff

View file

@ -237,10 +237,10 @@ Phaser.Time.prototype = {
this.physicsElapsed = 1.0 * (this.elapsed / 1000);
// Clamp the delta
if (this.physicsElapsed > 1)
{
this.physicsElapsed = 1;
}
// if (this.physicsElapsed > 1)
// {
// this.physicsElapsed = 1;
// }
// Paused?
if (this.game.paused)