1.0.1 release - fixes issues in tile map collision, additional Animation stop checks and updated package license.

This commit is contained in:
Richard Davey
2013-09-15 03:58:38 +01:00
parent 49a6ba2c02
commit f069107e55
19 changed files with 358 additions and 84 deletions
+6 -1
View File
@@ -5,7 +5,7 @@ Phaser 1.0
Phaser is a fast, free and fun open source game framework for making desktop and mobile browser HTML5 games. It supports Canvas and WebGL rendering.
Version: 1.0.0 - Released: September 13th 2013
Version: 1.0.1 - Released: September 15th 2013
By Richard Davey, [Photon Storm](http://www.photonstorm.com)
@@ -116,8 +116,13 @@ Although Phaser 1.0 is a brand new release it is born from years of experience b
Change Log
----------
Version 1.0.1
* Added checks into every Group function to ensure that the Group has children before running them.
* Added optional flag to Group.create which allows you to set the default exists state of the Sprites.
* Sprite.animation.stop no longer needs an animation name parameter, will default to stopping the current animation.
* Fixed the license in package.json
* Fixed a logic bug in the separateTileX function that would sometimes cause tunneling of big sprites through small tiles.
Known Issues
------------
+1 -1
View File
File diff suppressed because one or more lines are too long
+68 -46
View File
@@ -1,7 +1,7 @@
/**
* Phaser - http://www.phaser.io
*
* v1.0.0 - Built at: Fri, 13 Sep 2013 16:50:35 +0000
* v1.0.1 - Built at: Sun, 15 Sep 2013 02:56:00 +0000
*
* @author Richard Davey http://www.photonstorm.com @photonstorm
*
@@ -34,7 +34,7 @@ var PIXI = PIXI || {};
*/
var Phaser = Phaser || {
VERSION: '1.0.0',
VERSION: '1.0.1',
GAMES: [],
AUTO: 0,
CANVAS: 1,
@@ -8925,11 +8925,14 @@ Phaser.Group.prototype = {
},
create: function (x, y, key, frame) {
create: function (x, y, key, frame, exists) {
if (typeof exists == 'undefined') { exists = true; }
var child = new Phaser.Sprite(this.game, x, y, key, frame);
child.group = this;
child.exists = exists;
if (child.events)
{
@@ -9213,7 +9216,7 @@ Phaser.Group.prototype = {
checkVisible = checkVisible || false;
operation = operation || 0;
if (this._container.first._iNext)
if (this._container.children.length > 0 && this._container.first._iNext)
{
var currentNode = this._container.first._iNext;
@@ -9264,7 +9267,7 @@ Phaser.Group.prototype = {
var args = Array.prototype.splice.call(arguments, 2);
if (this._container.first._iNext)
if (this._container.children.length > 0 && this._container.first._iNext)
{
var currentNode = this._container.first._iNext;
@@ -9287,7 +9290,7 @@ Phaser.Group.prototype = {
if (typeof checkExists == 'undefined') { checkExists = false; }
if (this._container.first._iNext)
if (this._container.children.length > 0 && this._container.first._iNext)
{
var currentNode = this._container.first._iNext;
@@ -9308,7 +9311,7 @@ Phaser.Group.prototype = {
forEachAlive: function (callback, callbackContext) {
if (this._container.first._iNext)
if (this._container.children.length > 0 && this._container.first._iNext)
{
var currentNode = this._container.first._iNext;
@@ -9329,7 +9332,7 @@ Phaser.Group.prototype = {
forEachDead: function (callback, callbackContext) {
if (this._container.first._iNext)
if (this._container.children.length > 0 && this._container.first._iNext)
{
var currentNode = this._container.first._iNext;
@@ -9359,7 +9362,7 @@ Phaser.Group.prototype = {
state = true;
}
if (this._container.first._iNext)
if (this._container.children.length > 0 && this._container.first._iNext)
{
var currentNode = this._container.first._iNext;
@@ -9387,7 +9390,7 @@ Phaser.Group.prototype = {
*/
getFirstAlive: function () {
if (this._container.first._iNext)
if (this._container.children.length > 0 && this._container.first._iNext)
{
var currentNode = this._container.first._iNext;
@@ -9415,7 +9418,7 @@ Phaser.Group.prototype = {
*/
getFirstDead: function () {
if (this._container.first._iNext)
if (this._container.children.length > 0 && this._container.first._iNext)
{
var currentNode = this._container.first._iNext;
@@ -9444,7 +9447,7 @@ Phaser.Group.prototype = {
var total = -1;
if (this._container.first._iNext)
if (this._container.children.length > 0 && this._container.first._iNext)
{
var currentNode = this._container.first._iNext;
@@ -9473,7 +9476,7 @@ Phaser.Group.prototype = {
var total = -1;
if (this._container.first._iNext)
if (this._container.children.length > 0 && this._container.first._iNext)
{
var currentNode = this._container.first._iNext;
@@ -9503,6 +9506,11 @@ Phaser.Group.prototype = {
*/
getRandom: function (startIndex, length) {
if (this._container.children.length == 0)
{
return null;
}
startIndex = startIndex || 0;
length = length || this._container.children.length;
@@ -9539,6 +9547,11 @@ Phaser.Group.prototype = {
removeBetween: function (startIndex, endIndex) {
if (this._container.children.length == 0)
{
return;
}
if (startIndex > endIndex || startIndex < 0 || endIndex > this._container.children.length)
{
return false;
@@ -20558,15 +20571,25 @@ Phaser.AnimationManager.prototype = {
},
/**
* Stop animation by name.
* Stop animation. If a name is given that specific animation is stopped, otherwise the current one is stopped.
* Current animation will be automatically set to the stopped one.
*/
stop: function (name) {
if (this._anims[name])
if (typeof name == 'string')
{
this.currentAnim = this._anims[name];
this.currentAnim.stop();
if (this._anims[name])
{
this.currentAnim = this._anims[name];
this.currentAnim.stop();
}
}
else
{
if (this.currentAnim)
{
this.currentAnim.stop();
}
}
},
@@ -25466,7 +25489,6 @@ Phaser.Physics.Arcade.prototype = {
*/
separateTile: function (object, x, y, width, height, mass, collideLeft, collideRight, collideUp, collideDown, separateX, separateY) {
// Yes, the Y first
var separatedY = this.separateTileY(object.body, x, y, width, height, mass, collideUp, collideDown, separateY);
var separatedX = this.separateTileX(object.body, x, y, width, height, mass, collideLeft, collideRight, separateX);
@@ -25511,34 +25533,32 @@ Phaser.Physics.Arcade.prototype = {
// TODO - We need to check if we're already inside of the tile, i.e. jumping through an n-way tile
// in which case we didn't ought to separate because it'll look like tunneling
if (object.deltaX() < 0)
if (object.deltaX() > 0)
{
// Going right ...
this._overlap = object.x + object.width - x;
if ((this._overlap > this._maxOverlap) || !object.allowCollision.right || !collideLeft)
{
this._overlap = 0;
}
else
{
object.touching.right = true;
}
}
else if (object.deltaX() < 0)
{
// Going left ...
this._overlap = object.x - width - x;
if (object.allowCollision.left && collideLeft && this._overlap < this._maxOverlap)
if ((-this._overlap > this._maxOverlap) || !object.allowCollision.left || !collideRight)
{
this._overlap = 0;
}
else
{
object.touching.left = true;
// console.log('left', this._overlap);
}
else
{
this._overlap = 0;
}
}
else
{
// Going right ...
this._overlap = object.right - x;
if (object.allowCollision.right && collideRight && this._overlap < this._maxOverlap)
{
object.touching.right = true;
// console.log('right', this._overlap);
}
else
{
this._overlap = 0;
}
}
}
@@ -25605,13 +25625,14 @@ Phaser.Physics.Arcade.prototype = {
// Going down ...
this._overlap = object.bottom - y;
if (object.allowCollision.down && collideDown && this._overlap < this._maxOverlap)
// if (object.allowCollision.down && collideDown && this._overlap < this._maxOverlap)
if ((this._overlap > this._maxOverlap) || !object.allowCollision.down || !collideDown)
{
object.touching.down = true;
this._overlap = 0;
}
else
{
this._overlap = 0;
object.touching.down = true;
}
}
else
@@ -25619,13 +25640,13 @@ Phaser.Physics.Arcade.prototype = {
// Going up ...
this._overlap = object.y - height - y;
if (object.allowCollision.up && collideUp && this._overlap < this._maxOverlap)
if ((-this._overlap > this._maxOverlap) || !object.allowCollision.up || !collideUp)
{
object.touching.up = true;
this._overlap = 0;
}
else
{
this._overlap = 0;
object.touching.up = true;
}
}
}
@@ -27658,6 +27679,7 @@ Phaser.TilemapLayer.prototype = {
for (var r = 0; r < this._tempTileBlock.length; r++)
{
// separateTile: function (object, x, y, width, height, mass, collideLeft, collideRight, collideUp, collideDown, separateX, separateY)
if (this.game.physics.separateTile(object, this._tempTileBlock[r].x * this.tileWidth, this._tempTileBlock[r].y * this.tileHeight, this.tileWidth, this.tileHeight, this._tempTileBlock[r].tile.mass, this._tempTileBlock[r].tile.collideLeft, this._tempTileBlock[r].tile.collideRight, this._tempTileBlock[r].tile.collideUp, this._tempTileBlock[r].tile.collideDown, this._tempTileBlock[r].tile.separateX, this._tempTileBlock[r].tile.separateY))
{
this._tempBlockResults.push({ x: this._tempTileBlock[r].x, y: this._tempTileBlock[r].y, tile: this._tempTileBlock[r].tile });
Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

File diff suppressed because one or more lines are too long
@@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.0" orientation="orthogonal" width="64" height="64" tilewidth="16" tileheight="16">
<tileset firstgid="1" name="tiles-1" tilewidth="16" tileheight="16">
<image source="tiles-1.png" width="272" height="64"/>
</tileset>
<layer name="Tile Layer 1" width="64" height="64">
<data encoding="csv">
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
19,19,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
</data>
</layer>
</map>
Binary file not shown.

After

Width:  |  Height:  |  Size: 286 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 443 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

+125
View File
@@ -0,0 +1,125 @@
<?php
$title = "Star Struck";
require('../head.php');
?>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render });
function preload() {
game.load.tilemap('level1', 'assets/games/starstruck/tiles-1.png', 'assets/games/starstruck/level1.json', null, Phaser.Tilemap.JSON);
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');
game.load.image('starBig', 'assets/games/starstruck/star2.png');
game.load.image('background', 'assets/games/starstruck/background2.png');
}
var map;
var player;
var facing = 'left';
var jumpTimer = 0;
var bg;
function create() {
game.stage.backgroundColor = '#000000';
bg = game.add.tileSprite(0, 0, 800, 600, 'background');
bg.scrollFactor.setTo(0, 0);
map = game.add.tilemap(0, 0, 'level1');
map.setCollisionRange(1, 20, true, true, true, true);
map.setCollisionRange(18, 47, true, true, true, true);
map.setCollisionRange(53, 69, true, true, true, true);
player = game.add.sprite(32, 32, 'dude');
player.body.bounce.y = 0.2;
player.body.collideWorldBounds = true;
player.animations.add('left', [0, 1, 2, 3], 10, true);
player.animations.add('turn', [4], 20, true);
player.animations.add('right', [5, 6, 7, 8], 10, true);
game.camera.follow(player);
}
function update() {
game.physics.collide(player, map);
player.body.velocity.x = 0;
player.body.acceleration.y = 500;
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
{
player.body.velocity.x = -150;
if (facing != 'left')
{
player.animations.play('left');
facing = 'left';
}
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
{
player.body.velocity.x = 150;
if (facing != 'right')
{
player.animations.play('right');
facing = 'right';
}
}
else
{
if (facing != 'idle')
{
player.animations.stop();
if (facing == 'left')
{
player.frame = 0;
}
else
{
player.frame = 5;
}
facing = 'idle';
}
}
if (game.input.keyboard.isDown(Phaser.Keyboard.UP) || game.input.keyboard.isDown(Phaser.Keyboard.SPACEBAR))
{
if (player.body.touching.down && game.time.now > jumpTimer)
{
player.body.velocity.y = -200;
jumpTimer = game.time.now + 500;
}
}
}
function render() {
// game.debug.renderSpriteCorners(p);
// game.debug.renderSpriteCollision(p, 32, 320);
// game.debug.renderText(player.body.velocity.y, 32, 32, 'rgb(255,255,255)');
// game.debug.renderText('left: ' + player.body.touching.left, 32, 32, 'rgb(255,255,255)');
// game.debug.renderText('right: ' + player.body.touching.right, 32, 64, 'rgb(255,255,255)');
}
})();
</script>
<?php
require('../foot.php');
?>
+1 -1
View File
@@ -17,7 +17,7 @@
"2d"
],
"author": "Richard Davey",
"license": "BSD",
"license": "MIT",
"readmeFilename": "README.md",
"gitHead": "1217bf4722768514fe15ff904dab59f848d146f4",
"devDependencies": {
+1 -1
View File
@@ -1,7 +1,7 @@
/**
* Phaser - http://www.phaser.io
*
* v1.0.0 - Built at: {buildDate}
* v1.0.1 - Built at: {buildDate}
*
* @author Richard Davey http://www.photonstorm.com @photonstorm
*
+1 -1
View File
@@ -3,7 +3,7 @@
*/
var Phaser = Phaser || {
VERSION: '1.0.0',
VERSION: '1.0.1',
GAMES: [],
AUTO: 0,
CANVAS: 1,
+14 -4
View File
@@ -163,15 +163,25 @@ Phaser.AnimationManager.prototype = {
},
/**
* Stop animation by name.
* Stop animation. If a name is given that specific animation is stopped, otherwise the current one is stopped.
* Current animation will be automatically set to the stopped one.
*/
stop: function (name) {
if (this._anims[name])
if (typeof name == 'string')
{
this.currentAnim = this._anims[name];
this.currentAnim.stop();
if (this._anims[name])
{
this.currentAnim = this._anims[name];
this.currentAnim.stop();
}
}
else
{
if (this.currentAnim)
{
this.currentAnim.stop();
}
}
},
+27 -29
View File
@@ -626,7 +626,6 @@ Phaser.Physics.Arcade.prototype = {
*/
separateTile: function (object, x, y, width, height, mass, collideLeft, collideRight, collideUp, collideDown, separateX, separateY) {
// Yes, the Y first
var separatedY = this.separateTileY(object.body, x, y, width, height, mass, collideUp, collideDown, separateY);
var separatedX = this.separateTileX(object.body, x, y, width, height, mass, collideLeft, collideRight, separateX);
@@ -671,34 +670,32 @@ Phaser.Physics.Arcade.prototype = {
// TODO - We need to check if we're already inside of the tile, i.e. jumping through an n-way tile
// in which case we didn't ought to separate because it'll look like tunneling
if (object.deltaX() < 0)
if (object.deltaX() > 0)
{
// Going right ...
this._overlap = object.x + object.width - x;
if ((this._overlap > this._maxOverlap) || !object.allowCollision.right || !collideLeft)
{
this._overlap = 0;
}
else
{
object.touching.right = true;
}
}
else if (object.deltaX() < 0)
{
// Going left ...
this._overlap = object.x - width - x;
if (object.allowCollision.left && collideLeft && this._overlap < this._maxOverlap)
if ((-this._overlap > this._maxOverlap) || !object.allowCollision.left || !collideRight)
{
this._overlap = 0;
}
else
{
object.touching.left = true;
// console.log('left', this._overlap);
}
else
{
this._overlap = 0;
}
}
else
{
// Going right ...
this._overlap = object.right - x;
if (object.allowCollision.right && collideRight && this._overlap < this._maxOverlap)
{
object.touching.right = true;
// console.log('right', this._overlap);
}
else
{
this._overlap = 0;
}
}
}
@@ -765,13 +762,14 @@ Phaser.Physics.Arcade.prototype = {
// Going down ...
this._overlap = object.bottom - y;
if (object.allowCollision.down && collideDown && this._overlap < this._maxOverlap)
// if (object.allowCollision.down && collideDown && this._overlap < this._maxOverlap)
if ((this._overlap > this._maxOverlap) || !object.allowCollision.down || !collideDown)
{
object.touching.down = true;
this._overlap = 0;
}
else
{
this._overlap = 0;
object.touching.down = true;
}
}
else
@@ -779,13 +777,13 @@ Phaser.Physics.Arcade.prototype = {
// Going up ...
this._overlap = object.y - height - y;
if (object.allowCollision.up && collideUp && this._overlap < this._maxOverlap)
if ((-this._overlap > this._maxOverlap) || !object.allowCollision.up || !collideUp)
{
object.touching.up = true;
this._overlap = 0;
}
else
{
this._overlap = 0;
object.touching.up = true;
}
}
}
+1
View File
@@ -326,6 +326,7 @@ Phaser.TilemapLayer.prototype = {
for (var r = 0; r < this._tempTileBlock.length; r++)
{
// separateTile: function (object, x, y, width, height, mass, collideLeft, collideRight, collideUp, collideDown, separateX, separateY)
if (this.game.physics.separateTile(object, this._tempTileBlock[r].x * this.tileWidth, this._tempTileBlock[r].y * this.tileHeight, this.tileWidth, this.tileHeight, this._tempTileBlock[r].tile.mass, this._tempTileBlock[r].tile.collideLeft, this._tempTileBlock[r].tile.collideRight, this._tempTileBlock[r].tile.collideUp, this._tempTileBlock[r].tile.collideDown, this._tempTileBlock[r].tile.separateX, this._tempTileBlock[r].tile.separateY))
{
this._tempBlockResults.push({ x: this._tempTileBlock[r].x, y: this._tempTileBlock[r].y, tile: this._tempTileBlock[r].tile });