質問

I am using cocos2d-x 2.1.4 and would like to use the same image file e.g. spritesheet.png for

  1. the tiles on a tmx map built using Tiled Map Editor as well as;
  2. in-game sprites, which I usually make the spritesheet using TexturePacker.

The reason for combining is to reduce the number of draw calls, since there is enough texture space for the sprites and tiles to all be shared on one image. If I used TexturePacker with Tiled, I think I would have to reassign tile positions every time TexturePacker rearranges the tile images, so that is not a good approach.

I know I can get a CCTexture2D* from a CCSpriteframe, which I wanted to try to insert into CCTextureCache, so that the CCTMXLayer can pick up the texture (which is actually from a spritesheet). However, there is no method to do so.

What is the common technique of dealing with a combined spritesheet for both tiles and sprites in cocos2d-x?

役に立ちましたか?

解決

Change the sort algorithm in TP to name, then prefix your tile sprite images with _ or some other character to make sure they come first in the sprite sheet. You may want to create dummy tiles to reserve space for potential future tiles to avoid the risk of the tile sprites being rearranged when you add some more tiles in between.

Regardless of that, one additional draw call isn't going to make a difference.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top