Tilemap.createFromObjects can now turn a bunch of Tiled objects into Sprites in one single call, and copies across all properties as well.

This commit is contained in:
photonstorm
2013-12-22 04:27:12 +00:00
parent 63d90a0176
commit bf72b4d3b0
7 changed files with 102 additions and 15 deletions
+5 -5
View File
@@ -84,13 +84,13 @@
"name":"",
"properties":
{
"alpha":"0.5"
},
"type":"",
"visible":true,
"width":0,
"x":454,
"y":307
"x":443,
"y":244
},
{
"gid":34,
@@ -112,7 +112,7 @@
"name":"",
"properties":
{
"alpha":"0.5"
},
"type":"",
"visible":true,
@@ -140,7 +140,7 @@
"name":"",
"properties":
{
"body.gravity.y":"5"
},
"type":"",
"visible":true,
+15 -3
View File
@@ -49,11 +49,23 @@
<object name="sun" type="collision" x="793" y="340" width="77" height="70">
<ellipse/>
</object>
<object gid="34" x="454" y="307"/>
<object gid="34" x="443" y="244">
<properties>
<property name="alpha" value="0.5"/>
</properties>
</object>
<object gid="34" x="483" y="267"/>
<object gid="34" x="513" y="237"/>
<object gid="34" x="513" y="237">
<properties>
<property name="alpha" value="0.5"/>
</properties>
</object>
<object gid="34" x="549" y="229"/>
<object gid="34" x="580" y="249"/>
<object gid="34" x="580" y="249">
<properties>
<property name="body.gravity.y" value="5"/>
</properties>
</object>
<object gid="34" x="610" y="278"/>
<object gid="34" x="639" y="309"/>
<object gid="34" x="662" y="342"/>
+4 -2
View File
@@ -20,12 +20,14 @@ function preload() {
// game.load.image('phaser', 'assets/sprites/mushroom2.png');
// game.load.image('phaser', 'assets/sprites/wabbit.png');
game.load.image('phaser', 'assets/sprites/arrow.png');
game.load.spritesheet('coin', 'assets/sprites/coin.png', 32, 32);
// game.load.image('phaser', 'assets/sprites/darkwing_crazy.png');
}
var cursors;
var map;
var coins;
var layer;
var layer2;
@@ -57,13 +59,13 @@ function create() {
// layer2.alpha = 0.5;
layer = map.createLayer('Tile Layer 1');
layer.scrollFactorX = 0.5;
// layer.debug = true;
layer.resizeWorld();
//coins =
map.createFromObjects(34, 'coin', 0)
// layer2 = game.add.tilemapLayer(0, 0, 400, 600, null, map, 0);
// layer.cameraOffset.x = 400;