mirror of
https://github.com/photonstorm/phaser
synced 2024-11-26 14:40:38 +00:00
Tilemap.createFromObjects has been strengthened so that will only create Sprites for matching gids/ids/names. It also only sets the Sprite width and height values if they are present in the Tiled data (thanks @pparke #2012)
This commit is contained in:
parent
22f7aacfcb
commit
5ffb5b558d
2 changed files with 29 additions and 32 deletions
|
@ -304,6 +304,7 @@ If you are an exceptional JavaScript developer and would like to join the Phaser
|
|||
* Line.rotate used a calculation method which resulted in the line growing (or shrinking) in length over time, the more it was rotated. The new method never changes the lines length.
|
||||
* BitmapText.font failed to pull the new font from the Phaser Cache, stopping it from updating properly (thanks @AbrahamAlcaina #2001)
|
||||
* Video.stop now removes the 'playing' event listener, which stop Videos set to loop from throwing errors after being destroyed.
|
||||
* Tilemap.createFromObjects has been strengthened so that will only create Sprites for matching gids/ids/names. It also only sets the Sprite width and height values if they are present in the Tiled data (thanks @pparke #2012)
|
||||
|
||||
For changes in previous releases please see the extensive [Version History](https://github.com/photonstorm/phaser/blob/master/CHANGELOG.md).
|
||||
|
||||
|
|
|
@ -398,50 +398,46 @@ Phaser.Tilemap.prototype = {
|
|||
return;
|
||||
}
|
||||
|
||||
var sprite;
|
||||
var found = false;
|
||||
|
||||
for (var i = 0, len = this.objects[name].length; i < len; i++)
|
||||
for (var i = 0; i < this.objects[name].length; i++)
|
||||
{
|
||||
if (typeof this.objects[name][i].gid !== 'undefined' && typeof gid === 'number')
|
||||
{
|
||||
if (this.objects[name][i].gid === gid)
|
||||
{
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
var found = false;
|
||||
var obj = this.objects[name][i];
|
||||
|
||||
if (typeof this.objects[name][i].id !== 'undefined' && typeof gid === 'number')
|
||||
if (obj.gid !== undefined && typeof gid === 'number' && obj.gid === gid)
|
||||
{
|
||||
if (this.objects[name][i].id === gid)
|
||||
{
|
||||
found = true;
|
||||
}
|
||||
found = true;
|
||||
}
|
||||
|
||||
if (typeof this.objects[name][i].name !== 'undefined' && typeof gid === 'string')
|
||||
else if (obj.id !== undefined && typeof gid === 'number' && obj.id === gid)
|
||||
{
|
||||
if (this.objects[name][i].name === gid)
|
||||
{
|
||||
found = true;
|
||||
}
|
||||
found = true;
|
||||
}
|
||||
else if (obj.name !== undefined && typeof gid === 'string' && obj.name === gid)
|
||||
{
|
||||
found = true;
|
||||
}
|
||||
|
||||
if (found)
|
||||
{
|
||||
sprite = new CustomClass(this.game, this.objects[name][i].x, this.objects[name][i].y, key, frame);
|
||||
var sprite = new CustomClass(this.game, parseFloat(obj.x, 10), parseFloat(obj.y, 10), key, frame);
|
||||
|
||||
sprite.name = this.objects[name][i].name;
|
||||
sprite.visible = this.objects[name][i].visible;
|
||||
sprite.name = obj.name;
|
||||
sprite.visible = obj.visible;
|
||||
sprite.autoCull = autoCull;
|
||||
sprite.exists = exists;
|
||||
|
||||
sprite.width = this.objects[name][i].width;
|
||||
sprite.height = this.objects[name][i].height;
|
||||
|
||||
if (this.objects[name][i].rotation)
|
||||
if (obj.width)
|
||||
{
|
||||
sprite.angle = this.objects[name][i].rotation;
|
||||
sprite.width = obj.width;
|
||||
}
|
||||
|
||||
if (obj.height)
|
||||
{
|
||||
sprite.height = obj.height;
|
||||
}
|
||||
|
||||
if (obj.rotation)
|
||||
{
|
||||
sprite.angle = obj.rotation;
|
||||
}
|
||||
|
||||
if (adjustY)
|
||||
|
@ -451,9 +447,9 @@ Phaser.Tilemap.prototype = {
|
|||
|
||||
group.add(sprite);
|
||||
|
||||
for (var property in this.objects[name][i].properties)
|
||||
for (var property in obj.properties)
|
||||
{
|
||||
group.set(sprite, property, this.objects[name][i].properties[property], false, false, 0, true);
|
||||
group.set(sprite, property, obj.properties[property], false, false, 0, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue