ceb Posted March 27, 2014 Share Posted March 27, 2014 Hi I have a problem were an tilemap object is not appearing the object should be coins please can anyone help? Game - http://justukfreebies.co.uk/games/random/ Code - http://justukfreebies.co.uk/games/random/js/main.js Link to comment Share on other sites More sharing options...
Heppell08 Posted March 27, 2014 Share Posted March 27, 2014 I have objects in my maps with tile map and i call them like this: setStuff: function() { firstGroup = this.add.group(); map.createFromObjects('anItem', 304/*itsJSONTileID*/, '/*Preloadedimagename*/ 'itemPic', 0, true, false, firstGroup /*added to the group*/); },then i kill like this:killItem: function(player, itemPic) { console.log('Overlap kill'); itemPic.kill(); },and have overlap like so:this.physics.overlap(player, firstGroup, this.killItem, null, this);You need to add the object layer to the map in TILED then export then add the code accordingly. Also worth noting im in 1.1.5 phaser and see you're using 1.1.6 phaser. I'm unsure on any difference made to the object layer but have a look at the posted code and see if it helps you. Link to comment Share on other sites More sharing options...
ceb Posted March 27, 2014 Author Share Posted March 27, 2014 Damn your code didnt work for me :/ I don't even know were to start with this problem. Link to comment Share on other sites More sharing options...
Heppell08 Posted March 27, 2014 Share Posted March 27, 2014 Are you adding another layer to your tilemap in TILED, setting it as object and loading in the image?There is quite a few steps to getting it working.First off: make a new layer in tiled and add the image for the coin to the layer inside tiled.Export the map and then scroll down the bottom of the new JSON file, it will hold the names you need for loading into phaser. After you have them steps complete, you need to add the group and then add to the group from the JSON. Hence the - map.createFromObjects code in the above posted code. Once they are in place you will see them ingame but have no interaction with them. You need to set the overlap with the player then the item then callback to a function. In the function kill the item, add to the score or whatever it is you want it do on overlap.Maybe look at the simpler parts of JSON code tilemap then look at the examples AND the JSON that accompanies the example and compare from the JSON to the code so you know what you are looking to add from it. Link to comment Share on other sites More sharing options...
ceb Posted March 27, 2014 Author Share Posted March 27, 2014 Mmm, I have got the coins working but on 2.0.0 version and the code is completely different. http://justukfreebies.co.uk/games/prac/ I want to take that and put it in my new code but it's still not working out. Any ideas? Link to comment Share on other sites More sharing options...
ceb Posted March 28, 2014 Author Share Posted March 28, 2014 Really could do with help on this so BUMP! Link to comment Share on other sites More sharing options...
Heppell08 Posted March 28, 2014 Share Posted March 28, 2014 It is possible because I do it myself but what I don't understand is that you have 2 versions. 1 works and the other does not. So can you not use the working version instead OR look at the working versions code and use it to better code into the version required.The information you need I have told you and there is examples and you have a working version. The only step now is to add that to your game you want it to work on. Link to comment Share on other sites More sharing options...
Recommended Posts