SalGnt

Members
  • Content Count

    9
  • Joined

  • Last visited

About SalGnt

  • Rank
    Newbie

Profile Information

  • Gender
    Male
  1. I have a similar problem, have you found a solution?
  2. By using a tileset that has margins I got the following error (because of the extra space given by margins I think): TileSet image dimensions do not match expected dimensions. The JSON file was created with Tiled. Here is the code I used: function preload() { game.load.tilemap('piramid', 'piramid.json', null, Phaser.Tilemap.TILED_JSON); game.load.image('tileSet', 'tiles.png', 16, 16);}function create() { map = game.add.tilemap('piramid'); map.addTilesetImage('tileSet'); map.setCollisionByExclusion([ ], true, 'level'); levelLayer = map.createLayer('level');} Am I missing something?
  3. Thanks! Now if I want to use different collisions for each level, I just have to use the code below or I have to pay attention to something else? map.setCollisionByExclusion([ ], true, "groundLayer");map.setCollisionByExclusion([ 1 ], true, "skyLayer");
  4. I noticed that generated map using a JSON level scheme (manually created or even generated using Tiled) may cause a problem with collisions. Here is my level file: { "height":16, "layers":[ { "data":[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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40, 40, 40, 40, 40, 40, 40, 40, 40], "height":16, "name":"groundLayer", "opacity":1, "type":"tilelayer", "visible":true, "width":16, "x":0, "y":0 }], "orientation":"orthogonal", "properties": { }, "tileheight":16, "tilesets":[ { "firstgid":1, "image":"https://dl.dropboxusercontent.com/u/18322837/JSFiddle/super_mario.png", "imageheight":64, "imagewidth":176, "margin":0, "name":"tiles", "properties": { }, "spacing":0, "tileheight":16, "tilewidth":16 }], "tilewidth":16, "version":1, "width":16}The collisions seem to work only if I remove the first layer (named skyLayer) from the JSON file. There is something wrong in my code or it is a bug? A live example is available here (to use the level with both layers change ".../level.json" into ".../level2.json" at the line 10). Thanks!
  5. Try with this: map.setCollisionByExclusion([ ], true, 'water');map.setCollisionByExclusion([ ], true, 'ground');map.setCollisionByExclusion([ ], true, 'tree');
  6. You forgot to specify the update function when you declared the game. var game = new Phaser.Game(480, 320, Phaser.CANVAS, "", {preload: preload, create: create, update: update});
  7. I don't think that there is an event for that but you can use a simple function like this: function detectWorldBoundsCollision(ObjectGoesHere) { if (Math.round(ObjectGoesHere.x) + ObjectGoesHere.width == GameGoesHere.world.width) { console.log("Right side reached!"); } else if (Math.round(ObjectGoesHere.x) == 0) { console.log("Left side reached!"); } else if (Math.round(ObjectGoesHere.y) == 0) { console.log("Top side reached!"); } else if (Math.round(ObjectGoesHere.y) + ObjectGoesHere.height == GameGoesHere.world.height) { console.log("Bottom side reached!"); }}Otherwise you can do something like this: // Set ObjectGoesHere.body.collideWorldBounds to false before.function detectOutOfBounds(ObjectGoesHere) { if (!ObjectGoesHere.inWorld) { console.log("Object out of world bounds!"); }}
  8. I had a similar issue. It has been fixed in the 1.1.5 release.