1
Support / Gaps within tk2dStaticSpriteBatcher
« on: February 03, 2013, 06:02:55 pm »
Hi !
I have gap issues when trying to fill a tk2dStaticSpriteBatcher with batched sprites (30x30 pixels).
I am using a custom sprite collection data (needed for dynamic resource loading)
PART 1 : Get the sprite collection data
PART 2 : the batcher
And, as I am getting the collection data from code, i did not found any way to set the Pad option to Extend.
Is there any way to remove these gaps ?
Thanks for your support.
I have gap issues when trying to fill a tk2dStaticSpriteBatcher with batched sprites (30x30 pixels).
I am using a custom sprite collection data (needed for dynamic resource loading)
PART 1 : Get the sprite collection data
Code: [Select]
Texture2D texture = tilesetPost.texture; // from WWW
int i = 0, nbSprites = (texture.width / 30) * (texture.height / 30);
Rect[] regions = new Rect[nbSprites];
Vector2[] anchors = new Vector2[nbSprites];
string[] names = new string[nbSprites];
Vector2 anchor = new Vector2(0, 0);
for (int y = 0; y < texture.height; y += 30)
{
for (int x = 0; x < texture.width; x += 30)
{
regions[i] = new Rect(x, y, 30, 30);
anchors[i] = anchor;
names[i] = (x/30) + "_" + (y/30);
++i;
}
}
tk2dRuntime.SpriteCollectionSize size = tk2dRuntime.SpriteCollectionSize.ForTk2dCamera();
tk2dSpriteCollectionData spriteData = tk2dSpriteCollectionData.CreateFromTexture(texture, size, names, regions, anchors);
PART 2 : the batcher
Code: [Select]
GameObject batcherObject = new GameObject("Batcher");
tk2dStaticSpriteBatcher batcher = batcherObject.AddComponent<tk2dStaticSpriteBatcher>();
batcher.spriteCollection = spriteData;
for (int y = 0; y < srcH; ++y)
{
for (int x = 0; x < srcW; ++x)
{
tk2dBatchedSprite sprite = new tk2dBatchedSprite();
sprite.spriteId = sprData.GetSpriteIdByName(x + "_" + y);
sprite.position = new Vector3(destX, destY, 0);
sprites.Add(sprite);
}
}
batcher.batchedSprites = sprites.ToArray();
batcher.Build();
And, as I am getting the collection data from code, i did not found any way to set the Pad option to Extend.
Is there any way to remove these gaps ?
Thanks for your support.