Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

i am working on a tile roguelike i got some of the basics working using this tutorial http://www.raywenderlich.com/1163/how-to-make-a-tile-based-game-with-cocos2d

but i want to be able to create a map programatically instead of using the tiled editor

just add a NSArray of sprites/tiles to my CCLayer derived class or something, or should i make use of the CCTMXTiledMap class?

can anyone gimme some hints about how to do this? or know of a tutorial or sample code somewhere?

thanks a lot

share|improve this question
    
I suggest looking into the CCTMXTileMap and CCTMXLayer class and see how they operate. Perhaps that will help you figure out if this is feasible. –  Moshe Jul 17 '11 at 12:59

1 Answer 1

up vote 4 down vote accepted

You only need a CCTMXLayer, there is no need for any thing else. but you'll need to initialize it properly. for that reason I suggest you use some TMX file generated with Tiled editor and then load it into your program. there is a GID value for each tile in TMXLayer and you can easily edit it. by changing that value the tile for that position will change. if you set a tile's GID to 0 TMXLayer will automatically delete tile at that position otherwise, it'll change(or create) the ccSprite instance at that position.

share|improve this answer
    
This is a clever solution. It didn't occur to me just to load a "blank" map and then modify it to make it random. –  Clay Aug 28 '12 at 19:39

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.