0

I am building a game where the users (players) can build their own town. There they can build houses, add furniture to the houses etc etc. Basically similar to The Sims.

I am using the Tiled Map Editor to create a basis for each town. There I define the following layers

  • ground
  • floor
  • walls and furniture (basically everything)

All these layers are initially empty. It is up to the user to fill them.

I am using cocos2d v2 and its CCTMXTiledMap to render this tile map in my project.

One thing that I realised is that the layers defined in the map, CCTMXLayers, only support images from one tileset (#).

This has led to the following questions that I need to have answered before digging in to some serious game development.

Question 1. This game would be no fun if all my houses had the same walls. I really need numerous different kind of walls in the "walls and furniture" - tileset. How big can a tileset be? Note that I need to store not only different wall-textures here but also textures representing the furniture due to (#).

Question 2. The way you change the tiles in a CCTMXTiledMap is (as far as I know..?) using the setGID method for that particular layer. Going back to the example with different walls. Lets say the player can choose among different walls from a scrolling HUD-Layer menu. When a player selects a certain wall - how do I know which GID that particular wall has (during runtime)?

P.S I am very new to both cocos2d and Tiled so if I have taken the wrong approach here, please tell me what approach I should take in a game like this. I've been looking into Kobold Touch as well - perhaps that better suits my needs?

Eyeball
  • 3,267
  • 2
  • 26
  • 50

1 Answers1

0

1) Your tileset needs to stay within the texture size limits of your target device. You're basically always safe with 1024x1024 pixels but recent devices support up to 4096x4096. See http://www.uchidacoonga.com/2012/04/quick-tip-max-texture-size/

2) You get the GID by taking the local index of the tile in its tileset and adding the value of the tileset.firstGid property.

I would encourage you to look into Kobold Kit or maybe upgrading to a newer version of cocos2d (if they got rid of the one tileset per layer limitation). The one tileset per layer is an understandable limitation for performance reasons, but it's also quite annoying to work around if you need to.

Thorbjørn Lindeijer
  • 2,022
  • 1
  • 17
  • 22