j0hnskot Posted June 7, 2014 Share Posted June 7, 2014 Hello! Is it possible to create a sprite from an object without giving a gid? What i want is to create sprites based on an object created in tiled with "Insert rectangle" and not "Insert Tile". Link to comment Share on other sites More sharing options...
wayfinder Posted June 7, 2014 Share Posted June 7, 2014 You can name your rectangles in the object pane! Link to comment Share on other sites More sharing options...
j0hnskot Posted June 7, 2014 Author Share Posted June 7, 2014 Yes i can , but how i find them with phaser? Link to comment Share on other sites More sharing options...
wayfinder Posted June 7, 2014 Share Posted June 7, 2014 assuming you have loaded the tilemap, you will find a layer in there by the name of your object layer, and inside that the rectangles. Link to comment Share on other sites More sharing options...
j0hnskot Posted June 7, 2014 Author Share Posted June 7, 2014 I tried this.layer2=this.map.createLayer('Spikes');where 'Spikes" is my object layer and it give me a warning : Tilemap.createLayer: Invalid layer ID given: null What am i doing wrong? Here is the link of my map, check it if you can! https://dl.dropboxusercontent.com/u/10178928/platformer/assets/maps/2.json Link to comment Share on other sites More sharing options...
wayfinder Posted June 7, 2014 Share Posted June 7, 2014 It's an objectgroup, so you'd have to use map.createFromObjects edit: sorry, rereading what i wrote, it does confuse.. give me a second Link to comment Share on other sites More sharing options...
wayfinder Posted June 7, 2014 Share Posted June 7, 2014 so it should be this.map.createFromObjects(spikesgroup, 'Spikes', 'spikeimagename');where spikesgroup is the group for your sprite objects, and 'spikeimagename' is the key of the graphic you want to use Link to comment Share on other sites More sharing options...
j0hnskot Posted June 7, 2014 Author Share Posted June 7, 2014 Shouldn't the first value be "Spikes" since it needs the name i used on tiled for this object group? I used this this.map.createFromObjects('Spikes', 'Spikes', 'spikes_bottom', 0, true, false, this.spikes);The first value is the name of the Object group, the second should be a gid but since it doesn't have one i thought that the 'layer name within the map data' should be the same as the name of the object group. But this doesn't work! Link to comment Share on other sites More sharing options...
wayfinder Posted June 7, 2014 Share Posted June 7, 2014 Oh, indeed, i am sorry! I don't know why your code doesn't work then, sorry! Link to comment Share on other sites More sharing options...
j0hnskot Posted June 7, 2014 Author Share Posted June 7, 2014 Well,there it goes my hope Thank you for your time! Actually, i've changed the source of createFromObjects to be able to load those groups correctly. But i feel there is something i'm missing. Link to comment Share on other sites More sharing options...
valueerror Posted June 8, 2014 Share Posted June 8, 2014 well... afaik phaser can handle polygons painted with the polyline tool and transform them into physics bodies (not sprites.. at least not directly) and tiles on the object layer canbe transformed into sprites via a given id... correct me if i'm wrong but i think thats it.. you cant use the rectangle tool at all... but why wouldnt you just place a little tile instead of the rectangle.. whats the problem with it? Link to comment Share on other sites More sharing options...
j0hnskot Posted June 8, 2014 Author Share Posted June 8, 2014 The reason is that i use the automap on Tiled.Creating objects with different properties take ages to make and place by hand. So i decided to use automapping to make it faster. But Tiled currently bugs out if you use a tile as an object and results to not placing an object at all. It only works with rectangles (or other shapes) so if i want to use automaping to place objects there is no other way but to use rectangles. Link to comment Share on other sites More sharing options...
valueerror Posted June 9, 2014 Share Posted June 9, 2014 ahh.. ok. never used automapping.. i place objects by hand (tiles) and yes.. it's a lot of work but i create different objects with different properties once and then just copy them.. Link to comment Share on other sites More sharing options...
j0hnskot Posted June 9, 2014 Author Share Posted June 9, 2014 That's a way yes, but if i some time want to change a value of 100 tiles it will take much time! But with automaping you just press a button to make changes. Thanks for your help! Link to comment Share on other sites More sharing options...
Recommended Posts