Welcome to my Programming Blog...

I am currently working on a couple of projects: An original game called "Implosion" which I am porting from Flash to the iPad, and a remake of Q*bert in Python (pygame), as part of the class I am teaching. Please feel free to use the "Labels" (at right) to follow a specific project or theme. If you are one of my Python students, I recommend that you check out the Python thread.

Tuesday, January 11, 2011

Making a TileMap in cocos2d

Here's how to get an orthoganal tilemap in your iphone game. This is largely based on work by Ray Wenderlich and Steffen Itterheim.

Step 1: Create some tiles

  1. Launch SternTiles, make a new file and pick a tile size for your project.
  2. Create some tiles! You can always come back and edit them or add more.
  3. Save your file and add (copy) it to your project folder.


Step 2: Design the tile map

  1. Open up Tiled and create a new document. Pick how many tiles should show up in your map (getting over 100 x 100 would be pushing it...) and the size of the tiles you chose in SternTiles.
  2. Go to the Map menu and select "New Tileset..." Click on the "Browse" button and navigate to the copy of the tilesheet file you made in SternTiles that lives in your project's "Resources" folder.
  3. Start drawing away!
  4. To create a starting point for your character: 
    1. Go to the Layer menu and choose "New Object Layer." Name this layer "Objects," or something like that - don't forget what it is. 
    2. Draw a small box on the screen in this layer - the lower left corner will be the starting location for your player.
    3. Right-click (control-click) on the box and select "object properties" for the name, type in "playerStart" or something like that.
    4. (Note: you can also use this to place other objects in the world, such as keys, coins, monster spawn points, etc. Just make sure that each of these objects has a unique name.)
  5. To manage collisions, you can create another layer for obstacles. 
    1. Go to the Layer menu and create a new Tile Layer.
    2. Use another tile (like a solid red tile) to draw on the obstacle layer over all the objects that are "solid" on the background.
    3. In the tileset, right-click (control-click) on the tile you used and select "Tile Properties." Add a new key/value pair that says "solid"|"True."
    4. (Ideas: You can also repeat this process if you want to have areas that slow the player down or have other features (like traps!) associated with certain squares on the grid)
    5. Save your file - you can always come back and make changes!

No comments:

Post a Comment