abdul Posted September 14, 2014 Share Posted September 14, 2014 I am testing a racing car game. For that I make my road in tiled map editor and using its json file in phaser. It is 50 tiles in height. Now I want to extend my map. I have two options , extend it through phaser or make whole extended map in tiled map editor. Which one is better and how can I extend it through phaser ? I have no idea about this.I also want to add an object layer on my background layer, so that my car collides with other objects which will be on my background layer. I have already searched object layer problem in this forum, but not satisfied.I am also attaching files , may be I am not clearing my question...plz help me out..test game.zip Link to comment Share on other sites More sharing options...
nak3ddogs Posted September 15, 2014 Share Posted September 15, 2014 In examples u can find the object layer at tilemap. But im from mobile and i cant link. I have no idea for your first question. Link to comment Share on other sites More sharing options...
abdul Posted September 15, 2014 Author Share Posted September 15, 2014 I know about that example I want to use it in another way, but my main problem is my first question... Link to comment Share on other sites More sharing options...
lewster32 Posted September 15, 2014 Share Posted September 15, 2014 How do you want to extend your map? If you want to programmatically add more to the map, your best route is probably to generate the JSON data the TileMap is expecting within your game, but this won't be trivial. I think for the moment you'd be better off creating your full track in Tiled, including all of the outside areas of the track that a player would be able to see. Link to comment Share on other sites More sharing options...
abdul Posted September 15, 2014 Author Share Posted September 15, 2014 yp, I want to add more to the map programmatically, but according to you if it is difficult for new one and its better to create full track in tiled, then I will make whole map in tiled map editor.. Link to comment Share on other sites More sharing options...
abdul Posted September 16, 2014 Author Share Posted September 16, 2014 I make my whole map in tiled, and it has 2 layers. Now when I move my car, it only covers few distance and then stop, I don't know why it is not covering full map. I am attaching files test game.zip I don't know what is missing or wrong in it.. and second thing is that, in first layer I have road and in second layer I have footpath, I want that car drives on road and collide with footpath. but what should I do for that ? I set collision of my car with both layers, should I make my second layer object layer ? or there is any other way to handle this. Link to comment Share on other sites More sharing options...
lewster32 Posted September 16, 2014 Share Posted September 16, 2014 For your first question, the problem was you were calling resizeWorld twice, so change your onCreate function to this: function onCreate() { // game.stage.backgroundColor = '#6b6b9d'; map = game.add.tilemap('map'); //preloaded tilemap map.addTilesetImage('roadNS','tileset'); // preloaded tileset image map.addTilesetImage('roadNE','tileset2'); // preloaded tileset image map.addTilesetImage('roadNW','tileset3'); // preloaded tileset image map.addTilesetImage('roadSE','tileset4'); // preloaded tileset image map.addTilesetImage('roadSW','tileset5'); // preloaded tileset image map.addTilesetImage('roadNEWS','tileset6'); // preloaded tileset image layer1 = map.createLayer('background'); //default name of the layer in map layer2 = map.createLayer('Tile Layer 2'); //default name of the layer in map layer1.resizeWorld(); // sets the world size to match the size of the layer map.setCollisionBetween(0,382,true,layer1); map.setCollisionBetween(0,306,true,layer2); layer1.debug = true; layer2.debug = true; //game.physics.startSystem(Phaser.Physics.P2JS); game.physics.startSystem(Phaser.Physics.ARCADE); car = game.add.sprite(110,game.world.height-100,'car'); // Set the rotation point of the car to be dead-centre, otherwise the car will turn // strangely and the collision box will be less predictably placed. car.anchor.set(0.5); car.angle = -90; // point the car up //game.physics.p2.enable(car); game.physics.arcade.enable(car); // Because of limitations with Arcade physics and rotation we need to ensure the body is // square. This means the collisions will be more reliable regardless of the orientation // of the car. car.body.setSize(32, 32); car.body.maxVelocity.setTo(MAX_SPEED, MAX_SPEED ); //x,y car.body.drag.setTo(DRAG,DRAG); cursors = game.input.keyboard.createCursorKeys(); game.camera.follow(car); }I'm afraid I can't help much with the TileMap specific questions as I've not used TileMaps myself yet. abdul 1 Link to comment Share on other sites More sharing options...
abdul Posted September 16, 2014 Author Share Posted September 16, 2014 thank you @lewster32, you solve my first problem.. Link to comment Share on other sites More sharing options...
Recommended Posts