Jump to content

Overlapping and tiled problem


blackbeardt
 Share

Recommended Posts

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

Link to comment
Share on other sites

You might be interested in processCallbackhttp://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

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...