mirror of
https://github.com/photonstorm/phaser
synced 2024-09-20 14:31:55 +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.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)
|
||||
|
||||
* 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
|
||||
|
||||
|
@ -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)
|
||||
* 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)
|
||||
* 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).
|
||||
|
||||
|
|
|
@ -402,6 +402,11 @@ Phaser.Tilemap.prototype = {
|
|||
sprite.autoCull = autoCull;
|
||||
sprite.exists = exists;
|
||||
|
||||
if (this.objects[name][i].rotation)
|
||||
{
|
||||
sprite.angle = this.objects[name][i].rotation;
|
||||
}
|
||||
|
||||
if (adjustY)
|
||||
{
|
||||
sprite.y -= sprite.height;
|
||||
|
|
|
@ -256,20 +256,28 @@ Phaser.TilemapParser = {
|
|||
rotation = 0;
|
||||
flipped = false;
|
||||
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;
|
||||
if(gid>0x80000000) // FlippedX
|
||||
|
||||
// FlippedX
|
||||
if (gid > 0x80000000)
|
||||
{
|
||||
gid -= 0x80000000;
|
||||
flippedVal += 4;
|
||||
}
|
||||
if(gid>0x40000000) // FlippedY
|
||||
|
||||
// FlippedY
|
||||
if (gid > 0x40000000)
|
||||
{
|
||||
gid -= 0x40000000;
|
||||
flippedVal += 2;
|
||||
}
|
||||
if(gid>0x20000000) // FlippedAD
|
||||
|
||||
// FlippedAD
|
||||
if (gid > 0x20000000)
|
||||
{
|
||||
gid -= 0x20000000;
|
||||
flippedVal += 1;
|
||||
|
@ -304,6 +312,7 @@ Phaser.TilemapParser = {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// index, x, y, width, height
|
||||
if (gid > 0)
|
||||
{
|
||||
|
@ -404,11 +413,19 @@ Phaser.TilemapParser = {
|
|||
var collision = {};
|
||||
|
||||
function slice (obj, fields) {
|
||||
|
||||
var sliced = {};
|
||||
for (var k in fields) {
|
||||
|
||||
for (var k in fields)
|
||||
{
|
||||
var key = fields[k];
|
||||
|
||||
if (obj[key])
|
||||
{
|
||||
sliced[key] = obj[key];
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
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 = [];
|
||||
|
||||
// Parse the polyline into an array
|
||||
|
@ -470,14 +497,16 @@ Phaser.TilemapParser = {
|
|||
else if (json.layers[i].objects[v].polygon)
|
||||
{
|
||||
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
|
||||
object.polygon = [];
|
||||
|
||||
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 ]);
|
||||
}
|
||||
|
||||
objects[json.layers[i].name].push(object);
|
||||
|
||||
}
|
||||
|
@ -485,14 +514,14 @@ Phaser.TilemapParser = {
|
|||
else if (json.layers[i].objects[v].ellipse)
|
||||
{
|
||||
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);
|
||||
}
|
||||
// otherwise it's a rectangle
|
||||
else
|
||||
{
|
||||
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;
|
||||
objects[json.layers[i].name].push(object);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue