cykod / Quintus

HTML5 Game Engine
http://html5quintus.com
GNU General Public License v2.0
1.41k stars 401 forks source link

Multiple Tile Layers in TMX file #80

Closed jbasinger closed 10 years ago

jbasinger commented 10 years ago

Hello, I'm trying to use Tiled and the TMX files to make a level for a proof of concept. I followed the platformer example and was able to add a collision layer very simply and it worked like a charm once I added the collision=true property to the layer. Then I tried to add another Tile Layer through Tiled. Now I'm getting some very funny collision.

My map is 50x50 tiles with the tiles being 32x32 pixels so the map is 1600x1600 pixels. For some reason, once I add the second Tile Layer I can't move my character anywhere within the first 800x800 pixels of the map. Even if I remove the collision=true from the collision layer, I still collide. This is top down style movement so the player can go up, down left and right. No gravity.

I tried forking the code and attempted to find the issue myself, but I'm not familiar enough with how the collision is implemented to figure it out yet. I think it might have something to do with setting up collision points in here: https://github.com/cykod/Quintus/blob/master/lib/quintus_sprites.js#L311

If you can give me an idea of where to start looking I don't mind trying to figure out the problem =)

cykod commented 10 years ago

set the type: 0 to the second tile layer - you're colliding with a non-collision layer tile layer, which means it'll collide with the object as if it was a big square sprite.

jbasinger commented 10 years ago

That was it! Aaaaand now I feel dumb. Thanks =)

Out of curiosity, is there any reason that isn't the type by default?

frootmig commented 8 years ago

Can somebody tell me how to set type: 0 to the second tile layer?

chelBot commented 8 years ago

1) Right click on the layer you want. 2) Layer Properties. 3) Add property (lower left, blue plus sign). If you have multiple background layers be sure to add type: 0 to all of them.