blackbeardt Posted May 31, 2016 Share Posted May 31, 2016 Hello fellow phaser users I have been playing around a bit with tiled to make my 2D maps for a phaser game. But I have 2 problems that I cant seem to find the answer to : I made myself a script that a pokemon appears if I run on a specific layer. But I'm a bit stuck it keeps on finding pokemons because it keeps on saying that i'm in touch with the layer. var pokemonwild = game.physics.arcade.overlap(player, layerbackground); console.log(pokemonwild) This is what I am using right now. What should I add so it only checks once for an overlap each time I move? Also a small problem I cant get solved in tiled I made a layer named " frontgroundLayer" as purpose that it has to hide the player if it runs into that layer. For exmaple if the player runs into long grass you will see the long grass instead of the player. I have no problems with making them collide I just cant seem to find a way for the player to hide behind a tree for example. Thanks for the read hopefully anyway can help me Kind regards WombatTurkey 1 Link to comment Share on other sites More sharing options...
WombatTurkey Posted June 4, 2016 Share Posted June 4, 2016 You might be interested in processCallback : http://phaser.io/docs/2.4.4/Phaser.Physics.Arcade.html#overlap There, you can then set a variable to that player if they have already collided (or found a monster) to return false, so the overlap doesn't trigger Then, once the battle is done, set it back to true until they find a pokemon again (walking around in the grass or whatever) Although, an onBodyEnter would be a nice method to have Link to comment Share on other sites More sharing options...
drhayes Posted June 6, 2016 Share Posted June 6, 2016 If you create the player after you create your "frontgroundLayer" then the player will be in front of the layer. You need to make the player before you make the layer you want to appear in front. Link to comment Share on other sites More sharing options...
Recommended Posts