开发者

creating CCTMXLayer dynamically

I try to create my own tile map dynamically such as some buildings created with the help of database. I try to use CCSprite on object layers. However, when i scroll the map, also CCSprites' move too. 开发者_开发知识库I don't want to move all of the Sprites whenever player scrolls the map. (For performance issues) Then, I decided to create my own CCTMXLayer over the background layer. How can i create my own CCTMXLayer dynamically?


You can modify an existing tilemap using CCTMXLayer's setTileGID method, so create a tileMap in Tiled (or whatever editor you choose) with a single tile.

Then once you have loaded the map into a CCTMXLayer use the setTileGID to change what the tiles are.

Alternatively you could create a new CCLayer and then just add a sprite for every tile in the game, however, you should probably user a textureAtlas or a batchNode if you decide to take that approach. Then to move the map you just change the position of that layer.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜