1
Support / Re: Perfect gap with tk2dStaticSpriteBatcher
« on: May 11, 2013, 07:27:37 pm »
Thanks, working perfectly.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
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);