mirror of
https://github.com/photonstorm/phaser
synced 2025-02-18 15:08:31 +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.
|
* 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)
|
* 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.
|
* 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).
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var sprite;
|
for (var i = 0; i < this.objects[name].length; i++)
|
||||||
var found = false;
|
|
||||||
|
|
||||||
for (var i = 0, len = this.objects[name].length; i < len; i++)
|
|
||||||
{
|
{
|
||||||
if (typeof this.objects[name][i].gid !== 'undefined' && typeof gid === 'number')
|
var found = false;
|
||||||
{
|
var obj = this.objects[name][i];
|
||||||
if (this.objects[name][i].gid === gid)
|
|
||||||
{
|
|
||||||
found = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else if (obj.id !== undefined && typeof gid === 'number' && obj.id === gid)
|
||||||
if (typeof this.objects[name][i].name !== 'undefined' && typeof gid === 'string')
|
|
||||||
{
|
{
|
||||||
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)
|
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.name = obj.name;
|
||||||
sprite.visible = this.objects[name][i].visible;
|
sprite.visible = obj.visible;
|
||||||
sprite.autoCull = autoCull;
|
sprite.autoCull = autoCull;
|
||||||
sprite.exists = exists;
|
sprite.exists = exists;
|
||||||
|
|
||||||
sprite.width = this.objects[name][i].width;
|
if (obj.width)
|
||||||
sprite.height = this.objects[name][i].height;
|
|
||||||
|
|
||||||
if (this.objects[name][i].rotation)
|
|
||||||
{
|
{
|
||||||
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)
|
if (adjustY)
|
||||||
|
@ -451,9 +447,9 @@ Phaser.Tilemap.prototype = {
|
||||||
|
|
||||||
group.add(sprite);
|
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…
Add table
Reference in a new issue