To detect collisions (without using physics engines), the tutorial uses the method setPlayerPosition (in Part 2) for move the player if it can move…
If the player can’t move, the method doesn’t move the player.
The tutorial is very old.
Here you’ve a tutorial adapted to cocos 3.x (It is also old, but not so much )
And here you’ve cpp-examples:
However, I also have many doubts.
For example, in my case, getTileGIDAt always returns 0 and i don’t understand why. I think it’s because tileCoordForPosition is returning wrong tile positions.
Also, getProperty not works for me.
For example, i want to get this property: tileMap->getProperty("Width");
And i can’t. cc @drelaptop
Here i found how to fix the method tileCoordForPosition for cocos2d-x
And now the detection of collisions (without physics engine) works.
Tip: Be sure to add custom properties to the tile, otherwise, this line will give error: tileMap->getPropertiesForGID(tileGid).asValueMap();
EDIT:
As i could test… getTileGIDAt returns 0 when the tile coord is out of the layer.
Then, you could do something like this:
@slackmoehrle despite of you will update the documentation, there are any plans for update tiled maps in cocos2d-x? For example, i’m using Tiled tool (last version 1.2.1) for design the map.
Everything works fine but I always see this msg in the console: cocos2d: TMXFormat: Unsupported TMX version: 1.2
So, it sounds like “Tiled” is being updated and cocos not. There are any plans for update tiled map classes in cocos soon? To include the latest features that “Tiled” has (and fix bugs, why not).
Thanks
Also, i think cocos team should evaluate how to manage big tiled maps (IMHO).
At the moment, the map limit is 128x128. If i want to create a big map (example 512x512), i should create different tmx files and “concatenate” them (this is annoying for very big maps).
It would be great if all this work is managed by the framework.
For example, i would like to create 1024x1024 map in “Tiled” and the framework analyze how to create and load it. For example, create and remove new Tiles / SpriteBatchNode depending on the current visibility of the screen, etc. cc @stevetranby@drelaptop@zhangxm
I repeat, it’s only my humble opinion
EDIT:
I read that this topic has been discussed:
But i’m using the last version of cocos2d-x and i continue with the problem. The max size is 128x128 using cocos2d::TMXTiledMap.
What exactly is the name of the class? cocos2d::experimental::TMXTiledMap ?
If yes, why “experimental”? It sounds like it’s in beta. Will the final version be released soon?
What advantages does it have? I’m sorry but I don’t find documentation about this.
If I want to use a stable version, should i use cocos2d::TMXTiledMap instead of cocos2d::experimental::TMXTiledMap ?
It is been named experimental for a long time. And i don’t remember why it has the name, may be i have to ask Ricardo or Harisson for it. It is designed to have big map, only draw visible map and have int type for index which can hold more indices.
You can try it first. As i know it now has the same feature as normal tilemap, may be it doesn’t implement more features as wanted, so named experimental.
Currently, i am busy with metal support, so i can not put more energy on it right now. Sorry about it.