mirror of
https://github.com/photonstorm/phaser
synced 2025-02-17 06:28:30 +00:00
Merge branch 'dev' of https://github.com/photonstorm/phaser into dev
This commit is contained in:
commit
6cde583e82
9 changed files with 572 additions and 807 deletions
|
@ -148,6 +148,7 @@ Updates:
|
|||
* Removed the console.log redirect from Utils as it was messing with Firefox.
|
||||
* Body.acceleration is now much smoother and less eratic at high speeds.
|
||||
* Removed ArcadePhysics binding to the QuadTree, so it can now be used independantly of the physics system.
|
||||
* Removed ArcadePhysics.preUpdate and postUpdate as neither are needed any more.
|
||||
|
||||
|
||||
Bug Fixes:
|
||||
|
|
1212
build/phaser.js
1212
build/phaser.js
File diff suppressed because it is too large
Load diff
24
build/phaser.min.js
vendored
24
build/phaser.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -126,6 +126,10 @@
|
|||
"file": "offset+bounding+box.js",
|
||||
"title": "offset bounding box"
|
||||
},
|
||||
{
|
||||
"file": "process+callback.js",
|
||||
"title": "process callback"
|
||||
},
|
||||
{
|
||||
"file": "sprite+tiles.js",
|
||||
"title": "sprite tiles"
|
||||
|
@ -134,10 +138,6 @@
|
|||
"file": "sprite+vs+group.js",
|
||||
"title": "sprite vs group"
|
||||
},
|
||||
{
|
||||
"file": "sprite+vs+sprite+custom.js",
|
||||
"title": "sprite vs sprite custom"
|
||||
},
|
||||
{
|
||||
"file": "sprite+vs+sprite.js",
|
||||
"title": "sprite vs sprite"
|
||||
|
@ -620,6 +620,10 @@
|
|||
"file": "framerate+independence.js",
|
||||
"title": "framerate independence"
|
||||
},
|
||||
{
|
||||
"file": "gravity.js",
|
||||
"title": "gravity"
|
||||
},
|
||||
{
|
||||
"file": "launcher+follow+world.js",
|
||||
"title": "launcher follow world"
|
||||
|
@ -796,6 +800,10 @@
|
|||
"file": "sci+fly.js",
|
||||
"title": "sci fly"
|
||||
},
|
||||
{
|
||||
"file": "shuffle+tiles.js",
|
||||
"title": "shuffle tiles"
|
||||
},
|
||||
{
|
||||
"file": "swap+tiles.js",
|
||||
"title": "swap tiles"
|
||||
|
|
|
@ -68,7 +68,8 @@ function update() {
|
|||
fireBullet();
|
||||
}
|
||||
|
||||
game.physics.collide(bullets, veggies, collisionHandler, null, this);
|
||||
// As we don't need to exchange any velocities or motion we can use the faster 'overlap' check instead of 'collide':
|
||||
game.physics.overlap(bullets, veggies, collisionHandler, null, this);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload:
|
|||
function preload() {
|
||||
|
||||
game.load.tilemap('level1', 'assets/games/starstruck/level1.json', null, Phaser.Tilemap.TILED_JSON);
|
||||
game.load.tileset('tiles', 'assets/games/starstruck/tiles-1.png', 16, 16);
|
||||
game.load.image('tiles-1', 'assets/games/starstruck/tiles-1.png');
|
||||
game.load.spritesheet('dude', 'assets/games/starstruck/dude.png', 32, 48);
|
||||
game.load.spritesheet('droid', 'assets/games/starstruck/droid.png', 32, 32);
|
||||
game.load.image('starSmall', 'assets/games/starstruck/star.png');
|
||||
|
@ -32,20 +32,22 @@ function create() {
|
|||
|
||||
map = game.add.tilemap('level1');
|
||||
|
||||
tileset = game.add.tileset('tiles');
|
||||
map.addTilesetImage('tiles-1');
|
||||
|
||||
tileset.setCollisionRange(0, tileset.total - 1, true, true, true, true);
|
||||
map.setCollisionByExclusion([ 13, 14, 15, 16, 46, 47, 48, 49, 50, 51 ]);
|
||||
|
||||
tileset.setCollisionRange(12, 16, false, false, false, false);
|
||||
tileset.setCollisionRange(46, 50, false, false, false, false);
|
||||
layer = map.createLayer('Tile Layer 1');
|
||||
|
||||
// Un-comment this on to see the collision tiles
|
||||
// layer.debug = true;
|
||||
|
||||
layer = game.add.tilemapLayer(0, 0, 800, 600, tileset, map, 0);
|
||||
layer.resizeWorld();
|
||||
|
||||
game.physics.gravity.y = 260;
|
||||
|
||||
player = game.add.sprite(32, 32, 'dude');
|
||||
player.body.bounce.y = 0.2;
|
||||
player.body.collideWorldBounds = true;
|
||||
player.body.gravity.y = 6;
|
||||
player.body.setSize(16, 32, 8, 16);
|
||||
|
||||
player.animations.add('left', [0, 1, 2, 3], 10, true);
|
||||
|
@ -110,13 +112,10 @@ function update() {
|
|||
jumpTimer = game.time.now + 750;
|
||||
}
|
||||
|
||||
// player.scale.x += 0.001;
|
||||
// player.scale.y += 0.001;
|
||||
|
||||
}
|
||||
|
||||
function render () {
|
||||
|
||||
game.debug.renderSpriteBody(player);
|
||||
// game.debug.renderSpriteBody(player);
|
||||
|
||||
}
|
||||
|
|
39
examples/physics/gravity.js
Normal file
39
examples/physics/gravity.js
Normal file
|
@ -0,0 +1,39 @@
|
|||
|
||||
var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create });
|
||||
|
||||
function preload() {
|
||||
|
||||
game.load.image('ilkke', 'assets/sprites/ilkke.png');
|
||||
|
||||
}
|
||||
|
||||
var sprite1;
|
||||
var sprite2;
|
||||
var sprite3;
|
||||
|
||||
function create() {
|
||||
|
||||
game.stage.backgroundColor = '#2d2d2d';
|
||||
|
||||
// Set the world (global) gravity
|
||||
game.physics.gravity.y = 100;
|
||||
|
||||
// Sprite 1 will use the World (global) gravity
|
||||
sprite1 = game.add.sprite(300, 32, 'ilkke');
|
||||
sprite1.body.collideWorldBounds = true;
|
||||
sprite1.body.bounce.y = 0.8;
|
||||
|
||||
// Sprite 2 is set to ignore the global gravity and use its own value
|
||||
sprite2 = game.add.sprite(400, 32, 'ilkke');
|
||||
sprite2.body.collideWorldBounds = true;
|
||||
sprite2.body.bounce.y = 0.8;
|
||||
sprite2.body.allowGravity = false;
|
||||
sprite2.body.gravity.y = 100;
|
||||
|
||||
// Sprite 3 will use both the global gravity and its own value
|
||||
sprite3 = game.add.sprite(500, 32, 'ilkke');
|
||||
sprite3.body.collideWorldBounds = true;
|
||||
sprite3.body.bounce.y = 0.8;
|
||||
sprite3.body.gravity.y = 100;
|
||||
|
||||
}
|
|
@ -581,7 +581,6 @@ Phaser.Game.prototype = {
|
|||
else
|
||||
{
|
||||
this.plugins.preUpdate();
|
||||
this.physics.preUpdate();
|
||||
this.world.preUpdate();
|
||||
|
||||
this.stage.update();
|
||||
|
|
|
@ -34,6 +34,16 @@ Phaser.Physics.Arcade = function (game) {
|
|||
*/
|
||||
this.bounds = new Phaser.Rectangle(0, 0, game.world.width, game.world.height);
|
||||
|
||||
/**
|
||||
* @property {number} OVERLAP_BIAS - A value added to the delta values during collision checks.
|
||||
*/
|
||||
this.OVERLAP_BIAS = 4;
|
||||
|
||||
/**
|
||||
* @property {Phaser.QuadTree} quadTree - The world QuadTree.
|
||||
*/
|
||||
this.quadTree = new Phaser.QuadTree(this.game.world.bounds.x, this.game.world.bounds.y, this.game.world.bounds.width, this.game.world.bounds.height, this.maxObjects, this.maxLevels);
|
||||
|
||||
/**
|
||||
* @property {number} maxObjects - Used by the QuadTree to set the maximum number of objects per quad.
|
||||
*/
|
||||
|
@ -44,21 +54,6 @@ Phaser.Physics.Arcade = function (game) {
|
|||
*/
|
||||
this.maxLevels = 4;
|
||||
|
||||
/**
|
||||
* @property {number} OVERLAP_BIAS - A value added to the delta values during collision checks.
|
||||
*/
|
||||
this.OVERLAP_BIAS = 4;
|
||||
|
||||
/**
|
||||
* @property {Phaser.QuadTree} quadTree - The world QuadTree.
|
||||
*/
|
||||
this.quadTree = new Phaser.QuadTree(this, this.game.world.bounds.x, this.game.world.bounds.y, this.game.world.bounds.width, this.game.world.bounds.height, this.maxObjects, this.maxLevels);
|
||||
|
||||
/**
|
||||
* @property {number} quadTreeID - The QuadTree ID.
|
||||
*/
|
||||
this.quadTreeID = 0;
|
||||
|
||||
// Avoid gc spikes by caching these values for re-use
|
||||
|
||||
/**
|
||||
|
@ -157,6 +152,17 @@ Phaser.Physics.Arcade = function (game) {
|
|||
*/
|
||||
this._dy = 0;
|
||||
|
||||
/**
|
||||
* @property {number} _gravityX - Internal cache var.
|
||||
* @private
|
||||
*/
|
||||
this._gravityX = 0;
|
||||
|
||||
/**
|
||||
* @property {number} _gravityY - Internal cache var.
|
||||
* @private
|
||||
*/
|
||||
this._gravityY = 0;
|
||||
};
|
||||
|
||||
Phaser.Physics.Arcade.prototype = {
|
||||
|
@ -173,13 +179,13 @@ Phaser.Physics.Arcade.prototype = {
|
|||
|
||||
if (body.allowGravity)
|
||||
{
|
||||
this._gravityX = (this.gravity.x + body.gravity.x);
|
||||
this._gravityY = (this.gravity.y + body.gravity.y);
|
||||
this._gravityX = this.gravity.x + body.gravity.x;
|
||||
this._gravityY = this.gravity.y + body.gravity.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._gravityX = 0;
|
||||
this._gravityY = 0;
|
||||
this._gravityX = body.gravity.x;
|
||||
this._gravityY = body.gravity.y;
|
||||
}
|
||||
|
||||
// Rotation
|
||||
|
@ -223,24 +229,6 @@ Phaser.Physics.Arcade.prototype = {
|
|||
|
||||
},
|
||||
|
||||
/**
|
||||
* Called automatically by the core game loop.
|
||||
*
|
||||
* @method Phaser.Physics.Arcade#preUpdate
|
||||
* @protected
|
||||
*/
|
||||
preUpdate: function () {
|
||||
},
|
||||
|
||||
/**
|
||||
* Called automatically by the core game loop.
|
||||
*
|
||||
* @method Phaser.Physics.Arcade#postUpdate
|
||||
* @protected
|
||||
*/
|
||||
postUpdate: function () {
|
||||
},
|
||||
|
||||
/**
|
||||
* Checks for overlaps between two game objects. The objects can be Sprites, Groups or Emitters.
|
||||
* You can perform Sprite vs. Sprite, Sprite vs. Group and Group vs. Group overlap checks.
|
||||
|
|
Loading…
Add table
Reference in a new issue