Search the Community
Showing results for tags '2.10.3'.
-
tl;dr game.physics.startSystem(Phaser.Physics.ARCADE); GameMap = game.add.tilemap('GameMap'); GameMap.addTilesetImage('TileSet', 'TileSet'); under = GameMap.createLayer('Underground'); layer = GameMap.createLayer('TileMap'); trees = GameMap.createLayer('Collideables'); GameMap.setCollision(7,true, "TileMap" ); // Deep water 1 GameMap.setCollision(17,true, "TileMap" ); // Deep water 2 GameMap.setCollision(27, true, 'Underground'); // Darkness GameMap.setCollision(37, true, 'Collideables'); // Trees game console.logs an error " No such layer name: TileMap" So player doesn't collide with water in the begining of the game. If I switch to layer "underground" with: Player begins collision with water as if everything is okay. I also don't receive any errors about layers like "Collideables" and "Underground". I've rechecked the names in the TiledMap multiple times but can't seem to pinpoint the source of this problem. What is that all about?
-
Phaser CE v2.10.3 So I have 2 tile layers in my Tiled map that use the same tileset. One for terrain, second is for trees over the existing map and other stuff that needs alpha channels. Preload game.load.tilemap('GameMap', 'TestMap.json', null, Phaser.Tilemap.TILED_JSON); game.load.image('TileSet', 'img/TileSet.png'); Create game.physics.startSystem(Phaser.Physics.ARCADE); GameMap = game.add.tilemap('GameMap'); GameMap.addTilesetImage('TileSet', 'TileSet'); layer = GameMap.createLayer('TileMap'); trees = GameMap.createLayer('Collideables'); GameMap.setCollision(7); // Deep water 1 GameMap.setCollision(17); // Deep water 2 GameMap.setCollision(27); // Dark GameMap.setCollision(37); // Trees layer.resizeWorld(); player = game.add.sprite(spawnX, spawnY, 'player'); game.physics.arcade.enable(player); game.camera.follow(player); player.body.collideWorldBounds = true; player.anchor.x = 0.5; player.anchor.y = 0.5; Update player.body.velocity.x = player.body.velocity.y = 0; game.physics.arcade.collide(player, layer); game.physics.arcade.collide(player, trees); The RESULT: Map terrain with sand, dirt and water draws correctly. (They are variable "layer") Trees also are being drawn in the right locations (They are variable "trees") Everything works, except for collisions. Player "collides" with water that is in the "layer" layer. But even though trees are being drawn they player doesn't collide with them. I basically did the same thing to "trees" creating a layer from it, which instantly adds it's graphics btw, and setup the collisions the way I did to layers. I've no idea why the player collides with deep water but not the trees. I'm at a loss. Why would player collide with deep water but not the trees?