@cthulhuu wrote:
Hi. I've got a single 1024x1024 png file as a tileset (spritesheet) where each tile is sized as 32x32. I am trying to get one tile. I tried this first;
Sprite *tile = Sprite::create("terrain.png"); tile->setTextureRect(Rect(0, 0, 32, 32));
It's result is not what I want because it takes the second tile like below;
![]()
Other code I tried is;
Sprite *tile = Sprite::create("terrain.png"); auto tilePixelWidth = floor(tile->getContentSize().width / 32); auto tilePixelHeight = floor(tile->getContentSize().height / 32); tile->setTextureRect(Rect(0, 0, tilePixelWidth, tilePixelHeight));
I divided the width and height with 32 because there are 32 tiles in each row. But this also results like the first one;
Posts: 3
Participants: 2