Hello,
I try to use the tk2dStaticSpriteBatcher. But I've got a problem with the gap between the sprites composing the Static Sprite Batcher.
First I'm using a unity camera to keep the perspective view (add 3d model & background).
I want to create a background with tiled sprites and use the StaticSpriteBatcher to avoid to create many gameobject.
I succeed to display 4 by 4 tiles but the gap is a problem, position or scale I think...
How can I get the right sprite height & width ?
GameObject spriteBatcherGO = new GameObject("BGSpriteBatcher");
tk2dStaticSpriteBatcher staticSB = spriteBatcherGO.AddComponent<tk2dStaticSpriteBatcher>();
staticSB.spriteCollection = collectionLevel;
spriteBatcherGO.transform.localPosition = new Vector3(1, 1, 1);
spriteBatcherGO.transform.localScale = new Vector3(1f,1f,1f);
tk2dBatchedSprite[] batchedSpriteList = new tk2dBatchedSprite[4 * 4];
int index = 0;
for (int i = 0; i < 4; ++i)
{
for (int j = 0; j < 4; ++j)
{
tk2dBatchedSprite batchedSprite = new tk2dBatchedSprite();
batchedSprite.spriteId = (i % 2 == 0)?1:0;// black or white tile
batchedSprite.localScale = new Vector3(5.5f,5.5f,5.5f);
// 5.5f is a manual and not perfect number
batchedSpriteList[index] = batchedSprite;
++index;
}
}
staticSB.batchedSprites = batchedSpriteList;
staticSB.Build();
staticSB.transform.localScale = new Vector3(50f,50f,1f);
Edit : I tried with 2 cameras : one 2dtk (ortho) and a unity (perspective), worked fine in the editor, but the 2dtk camera didn't display anything on the built exe.