How to detect collision on a tiled map (*.tmx)

Hi Mates,

I’ve been testing Tiled with Cocos Creator and so far I can import the exported .tmx files from Tiled.
I’m just wondering how can I utilize the TileMap collision detection on my game.

Thank you very much in advance for your support.

Hi @RoZsClive

Yes, I’m also looking collision detection with tmx, however, I’ve been reading this:

http://cocos2d-x.org/docs/api-ref/creator/v1.3/classes/TiledLayer.html

I think one has to set properties in tiled (ex: collision ), then get the properties via the api above, could be wrong, but since I’m working on another game with Cocos Creator that deals with tiles, if I find the solution, will let you know…:slight_smile: God Bless…

Sincerely,

Sunday

Hi @RoZsClive

Check out these tutorials, maybe it can help you:

https://developer.tizen.org/development/articles/how-use-tiled-map-editor-cocos2d-html5

God Bless…

Sincerely,

Sunday

Hi @luke2125,

This looks like the one I’m looking for. I’ll try this and will let you know if I manage to make it work. Thanks

God bless.

the puzzle.fire in the examples collection under cases/tiledmap has collision detection.

It’s a nice place to start if you’re working with tile maps.

cheers

1 Like

Hi @fliegenfuerst

Thanks for the help, much appreciation…:slight_smile: I have a quick question though, regarding creating an isometric style game using Tiled, do you think it’s best to add the objects in tiledmap which include players, collisions, etc… animated sprites within Tiled, then manipulate within Cocos Creator with the tmx api, or 50 - 50 with Cocos Creator, which is much easier to implement? Or it’s just a decision by the developer? Thanks again for the guidance and help…God Bless…

Sincerely,

Sunday

sorry for the late reply,

I can’t really tell, I for one am planning to create colliders for tiles and loading them according to which tile is used (like for a growing plant that shouldn’t block the player from accessing the whole sprite but just a rectangle around the plant).

Before doing any such thing, I’ll be testing if the adding a player sprite to a barrier layer works by now. if this feature is still not fixed I’m thinking about making the collisionLayer using sprites (basically sacrificing the upside of using the tilemap in the first place) and if that won’t work I’ll either try cocos2d c++ or go to another engine entirely…

but let’s not give up hope yet

cheers

Hi @fliegenfuerst

It really is disheartening, that you would have to go through all that trouble…But I understand your point of view, I’m also considering making the move to another game engine. Nevertheless, I would like to wait and see the next 3 months, what features are installed into Cocos Creator. But like you said, let’s not give up hope yet…God Bless…

Sincerely,

Sunday