TilemapParser will now throw a warning if the tileset image isn't the right size for the tile dimensions (fixes #377)

This commit is contained in:
photonstorm 2014-02-21 16:57:45 +00:00
parent 3ac8fba9e8
commit 5a00a0ad97
4 changed files with 82 additions and 2 deletions

View file

@ -137,6 +137,7 @@ Updates:
* Device, Canvas and GamePad classes all updated for better CocoonJS support (thanks Videlais)
* BitmapData.alphaMask will draw the given image onto a BitmapData using an image as an alpha mask.
* The new GameObjectCreator (which you access via game.make or State.make) lets you easily create an object but NOT add it to the display list.
* TilemapParser will now throw a warning if the tileset image isn't the right size for the tile dimensions.
Bug Fixes:
@ -154,6 +155,8 @@ Bug Fixes:
* Previously using a Pixel Perfect check didn't work if the Sprite was rotated or had a non-zero anchor point, now works under all conditions + atlas frames.
* If pixelPerfect Input Sprites overlapped each other the pixel check wasn't taken into consieration in the Pointer move method.
* Updated Input.Mouse to use event.button not event.which, so the const reference from input.mouse.button is correct (thanks grimor)
* Text that was fixedToCamera would 'jitter' if the world scrolled. Now works as expected across all fixed objects.
TO DO:

View file

@ -0,0 +1,70 @@
var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create, update: update });
function preload() {
game.load.image('backdrop', 'assets/pics/remember-me.jpg');
game.load.image('mushroom', 'assets/sprites/mushroom2.png');
game.load.image('coke', 'assets/sprites/cokecan.png');
game.load.bitmapFont('desyrel', 'assets/fonts/desyrel.png', 'assets/fonts/desyrel.xml', null, 0, -32);
}
var cursors;
var mushroom;
function create() {
game.world.setBounds(0, 0, 1920, 1200);
game.add.image(0, 0, 'backdrop');
mushroom = game.add.sprite(400, 400, 'mushroom');
// Test Fixing an Image to the Camera
var fixie = game.add.image(100, 100, 'coke');
fixie.fixedToCamera = true;
// And tween it
game.add.tween(fixie.cameraOffset).to({ y: 500 }, 2000, Phaser.Easing.Bounce.Out, true, 0, 1000, true);
// Test Fixing a Sprite to the Camera
var fixie2 = game.add.sprite(600, 100, 'coke');
fixie2.fixedToCamera = true;
fixie2.inputEnabled = true;
fixie2.input.enableDrag();
// Test Fixing a Text to the Camera
var text = game.add.text(300, 32, 'arrows to move\ndrag the can ->');
text.fixedToCamera = true;
// Test fixing a BitmapText to the Camera
var text2 = game.add.bitmapText(270, 520, 'desyrel', 'Fixed to Camera!', 32);
text2.fixedToCamera = true;
game.camera.follow(mushroom);
cursors = game.input.keyboard.createCursorKeys();
}
function update() {
if (cursors.left.isDown)
{
mushroom.x -= 8;
}
else if (cursors.right.isDown)
{
mushroom.x += 8;
}
if (cursors.up.isDown)
{
mushroom.y -= 8;
}
else if (cursors.down.isDown)
{
mushroom.y += 8;
}
}

View file

@ -365,7 +365,7 @@ Phaser.BitmapData.prototype = {
if (this._dirty)
{
// Only needed if running in WebGL, otherwise this array will never get cleared down
if (this.game.renderType == Phaser.WEBGL)
if (this.game.renderType === Phaser.WEBGL)
{
PIXI.texturesToUpdate.push(this.baseTexture);
}

View file

@ -400,7 +400,14 @@ Phaser.TilemapParser = {
newSet.columns = (set.imagewidth - set.margin) / (set.tilewidth + set.spacing);
newSet.total = newSet.rows * newSet.columns;
tilesets.push(newSet);
if (newSet.rows % 1 !== 0 || newSet.columns % 1 !== 0)
{
console.warn('TileSet image dimensions do not match expected dimensions. Tileset width/height must be evenly divisible by Tilemap tile width/height.');
}
else
{
tilesets.push(newSet);
}
}
map.tilesets = tilesets;