Hi, I create a sprite sheet using TexturePacker in my last project.
But when I add it to the game, the position that I put images was changed.
If I use this, (the code without CCSpriteFrameCache
CCSprite* bloco = CCSprite::create(“block.png”);
the position works perfect
But if I use the this,
CCSprite* bloco = CCSprite::createWithSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(“block.png”));
the position was changed
Why this is happening?
I discover the problem.
When I get the width size of the CCSprite bloco, I get the size of the entire spritesheet, an not only the internal sprite that I want.
I use the following code:
bloco->setPosition(CCPointMake(bloco->getTexture()>getContentSize.width/2 + ,
bloco>getTexture()->getContentSize().height/2 + (iposY * HEIGHT_DISTANCE)+HEIGHT_BASE));
The upper case variables are constants that I have in my game.
It’s possible to get the width and height for an internal sprite in the spritesheet?