mirror of
https://github.com/photonstorm/phaser
synced 2024-11-10 15:14:47 +00:00
TilemapParser now supports Tiled 0.11 version maps which includes the rotation
property on all Object types.
Tilemap.createFromObjects now checks for a `rotation` property on the Object and if present will set it as the Sprite.angle (#1433)
This commit is contained in:
parent
ff04754bb8
commit
35a04b2f1e
3 changed files with 53 additions and 17 deletions
|
@ -70,7 +70,8 @@ Version 2.3.0 - "Tarabon" - in dev
|
||||||
* MSPointer.pointerDownCallback, pointerMoveCallback and pointerUpCallback all allow you to set your own event based callbacks.
|
* MSPointer.pointerDownCallback, pointerMoveCallback and pointerUpCallback all allow you to set your own event based callbacks.
|
||||||
* MSPointer.button now records which button was pressed down (if any)
|
* MSPointer.button now records which button was pressed down (if any)
|
||||||
* Phaser now supports rotated and flipped tiles in tilemaps, as exported from the Tiled map editor (thanks @nkholski #1608)
|
* Phaser now supports rotated and flipped tiles in tilemaps, as exported from the Tiled map editor (thanks @nkholski #1608)
|
||||||
|
* TilemapParser now supports Tiled 0.11 version maps which includes the `rotation` property on all Object types.
|
||||||
|
* Tilemap.createFromObjects now checks for a `rotation` property on the Object and if present will set it as the Sprite.angle (#1433)
|
||||||
|
|
||||||
### Updates
|
### Updates
|
||||||
|
|
||||||
|
@ -102,6 +103,7 @@ Version 2.3.0 - "Tarabon" - in dev
|
||||||
* TileSprites weren't destroying WebGL textures, leading to eventual out of memory errors (thanks @chacal #1563)
|
* TileSprites weren't destroying WebGL textures, leading to eventual out of memory errors (thanks @chacal #1563)
|
||||||
* P2.Body.clearCollision default values were incorrectly set to `false` if no parameters were provided, even though the docs said they were `true` (thanks @brianbunch #1597)
|
* P2.Body.clearCollision default values were incorrectly set to `false` if no parameters were provided, even though the docs said they were `true` (thanks @brianbunch #1597)
|
||||||
* BitmapText.font wouldn't update an internal Pixi property (fontName) causing the text to fail to change font (thanks @starnut #1602)
|
* BitmapText.font wouldn't update an internal Pixi property (fontName) causing the text to fail to change font (thanks @starnut #1602)
|
||||||
|
* Fixed issue in PIXI.Text where it was using the wrong string for descender text measurements.
|
||||||
|
|
||||||
For changes in previous releases please see the extensive [Version History](https://github.com/photonstorm/phaser/blob/master/CHANGELOG.md).
|
For changes in previous releases please see the extensive [Version History](https://github.com/photonstorm/phaser/blob/master/CHANGELOG.md).
|
||||||
|
|
||||||
|
|
|
@ -402,6 +402,11 @@ Phaser.Tilemap.prototype = {
|
||||||
sprite.autoCull = autoCull;
|
sprite.autoCull = autoCull;
|
||||||
sprite.exists = exists;
|
sprite.exists = exists;
|
||||||
|
|
||||||
|
if (this.objects[name][i].rotation)
|
||||||
|
{
|
||||||
|
sprite.angle = this.objects[name][i].rotation;
|
||||||
|
}
|
||||||
|
|
||||||
if (adjustY)
|
if (adjustY)
|
||||||
{
|
{
|
||||||
sprite.y -= sprite.height;
|
sprite.y -= sprite.height;
|
||||||
|
|
|
@ -256,23 +256,31 @@ Phaser.TilemapParser = {
|
||||||
rotation = 0;
|
rotation = 0;
|
||||||
flipped = false;
|
flipped = false;
|
||||||
gid = json.layers[i].data[t];
|
gid = json.layers[i].data[t];
|
||||||
if (gid > 0x20000000) // if true the current tile is flipped or rotated (Tiled TMX format)
|
|
||||||
|
// If true the current tile is flipped or rotated (Tiled TMX format)
|
||||||
|
if (gid > 0x20000000)
|
||||||
{
|
{
|
||||||
flippedVal=0;
|
flippedVal = 0;
|
||||||
if(gid>0x80000000) // FlippedX
|
|
||||||
|
// FlippedX
|
||||||
|
if (gid > 0x80000000)
|
||||||
{
|
{
|
||||||
gid-=0x80000000;
|
gid -= 0x80000000;
|
||||||
flippedVal+=4;
|
flippedVal += 4;
|
||||||
}
|
}
|
||||||
if(gid>0x40000000) // FlippedY
|
|
||||||
|
// FlippedY
|
||||||
|
if (gid > 0x40000000)
|
||||||
{
|
{
|
||||||
gid-=0x40000000;
|
gid -= 0x40000000;
|
||||||
flippedVal+=2;
|
flippedVal += 2;
|
||||||
}
|
}
|
||||||
if(gid>0x20000000) // FlippedAD
|
|
||||||
|
// FlippedAD
|
||||||
|
if (gid > 0x20000000)
|
||||||
{
|
{
|
||||||
gid-=0x20000000;
|
gid -= 0x20000000;
|
||||||
flippedVal+=1;
|
flippedVal += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (flippedVal)
|
switch (flippedVal)
|
||||||
|
@ -304,6 +312,7 @@ Phaser.TilemapParser = {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// index, x, y, width, height
|
// index, x, y, width, height
|
||||||
if (gid > 0)
|
if (gid > 0)
|
||||||
{
|
{
|
||||||
|
@ -404,11 +413,19 @@ Phaser.TilemapParser = {
|
||||||
var collision = {};
|
var collision = {};
|
||||||
|
|
||||||
function slice (obj, fields) {
|
function slice (obj, fields) {
|
||||||
|
|
||||||
var sliced = {};
|
var sliced = {};
|
||||||
for (var k in fields) {
|
|
||||||
|
for (var k in fields)
|
||||||
|
{
|
||||||
var key = fields[k];
|
var key = fields[k];
|
||||||
sliced[key] = obj[key];
|
|
||||||
|
if (obj[key])
|
||||||
|
{
|
||||||
|
sliced[key] = obj[key];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return sliced;
|
return sliced;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -438,6 +455,11 @@ Phaser.TilemapParser = {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (json.layers[i].objects[v].rotation)
|
||||||
|
{
|
||||||
|
object.rotation = json.layers[i].objects[v].rotation;
|
||||||
|
}
|
||||||
|
|
||||||
objects[json.layers[i].name].push(object);
|
objects[json.layers[i].name].push(object);
|
||||||
}
|
}
|
||||||
else if (json.layers[i].objects[v].polyline)
|
else if (json.layers[i].objects[v].polyline)
|
||||||
|
@ -455,6 +477,11 @@ Phaser.TilemapParser = {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (json.layers[i].objects[v].rotation)
|
||||||
|
{
|
||||||
|
object.rotation = json.layers[i].objects[v].rotation;
|
||||||
|
}
|
||||||
|
|
||||||
object.polyline = [];
|
object.polyline = [];
|
||||||
|
|
||||||
// Parse the polyline into an array
|
// Parse the polyline into an array
|
||||||
|
@ -470,14 +497,16 @@ Phaser.TilemapParser = {
|
||||||
else if (json.layers[i].objects[v].polygon)
|
else if (json.layers[i].objects[v].polygon)
|
||||||
{
|
{
|
||||||
var object = slice(json.layers[i].objects[v],
|
var object = slice(json.layers[i].objects[v],
|
||||||
["name", "type", "x", "y", "visible", "properties" ]);
|
["name", "type", "x", "y", "visible", "rotation", "properties" ]);
|
||||||
|
|
||||||
// Parse the polygon into an array
|
// Parse the polygon into an array
|
||||||
object.polygon = [];
|
object.polygon = [];
|
||||||
|
|
||||||
for (var p = 0; p < json.layers[i].objects[v].polygon.length; p++)
|
for (var p = 0; p < json.layers[i].objects[v].polygon.length; p++)
|
||||||
{
|
{
|
||||||
object.polygon.push([ json.layers[i].objects[v].polygon[p].x, json.layers[i].objects[v].polygon[p].y ]);
|
object.polygon.push([ json.layers[i].objects[v].polygon[p].x, json.layers[i].objects[v].polygon[p].y ]);
|
||||||
}
|
}
|
||||||
|
|
||||||
objects[json.layers[i].name].push(object);
|
objects[json.layers[i].name].push(object);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -485,14 +514,14 @@ Phaser.TilemapParser = {
|
||||||
else if (json.layers[i].objects[v].ellipse)
|
else if (json.layers[i].objects[v].ellipse)
|
||||||
{
|
{
|
||||||
var object = slice(json.layers[i].objects[v],
|
var object = slice(json.layers[i].objects[v],
|
||||||
["name", "type", "ellipse", "x", "y", "width", "height", "visible", "properties" ]);
|
["name", "type", "ellipse", "x", "y", "width", "height", "visible", "rotation", "properties" ]);
|
||||||
objects[json.layers[i].name].push(object);
|
objects[json.layers[i].name].push(object);
|
||||||
}
|
}
|
||||||
// otherwise it's a rectangle
|
// otherwise it's a rectangle
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var object = slice(json.layers[i].objects[v],
|
var object = slice(json.layers[i].objects[v],
|
||||||
["name", "type", "x", "y", "width", "height", "visible", "properties" ]);
|
["name", "type", "x", "y", "width", "height", "visible", "rotation", "properties" ]);
|
||||||
object.rectangle = true;
|
object.rectangle = true;
|
||||||
objects[json.layers[i].name].push(object);
|
objects[json.layers[i].name].push(object);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue