Jump to content

Two layers in one canvas?


Sgt.Hartman
 Share

Recommended Posts

Hi,

 

I'm new to Phaser and I was wondering:

 

I want to add 2 layers simultaneously to a canvas:

var game = new Phaser.Game(960, 640, Phaser.AUTO, '', { preload: preload, create: create, update: update });...game.world.setBounds(0, 0, worldWidth, worldHeight); // It's a big world, you knowlayer = game.add.tilemapLayer(0, 0, 960, 576, tileset, map, 0);layer2 = game.add.tilemapLayer(0, 500, 960, 64, tileset2, map, 0);

So in the first one the player moves around and, on layer2, buttons appear and dissapear as the player interacts with... well, everything.

How can I make the player collide with layer2?

 

Thanks in advance.

Link to comment
Share on other sites

Thanks Rich, but maybe I've been trying it for too long and my braincells hurt, because I can't get it to work.

 

Player collides with world bounds alright, but can't find a way to make it collide with the other layer :unsure:

I think I tried everything that comes to my mind. Any example I can check please?

 

Thanks!

 

EDIT:

 

Maybe I should explain myself a little bit more:

 

What I have in mind is:
'layer1', where the game happens (the world will be larger than de canvas).
'layer2', shown at the bottom of the screen. Deppending on the player's actions, will show different buttons, info, etc. (some kind of user GUI you could say). When on layer1 the player gets to the map limit, I want him to collide with layer1-layer2 limit.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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