About sprite sizes

About sprite sizes
0.0 0


Hi, I have some quastions about sprites:

  1. How cocos2dx works with sizing? I have texture 512x64 and I want to make a sprite from a part of it so I do next:

CCSprite *sprBtns = CCSprite::create(“gump/m_btns.png”);
But, I get rect smaller than it must be. How to transform pixel sizes to what cocos2dx whants?

  1. Why all sprites are large than they are? Is it nessesary to get there real size always set do


  1. If I create many sprites from different parts of same textures, will engine load it to memmory for each sprite or only once?


Ok, as i understand the problem was in setContentScaleFactor, it’s very strange - because in this case texture size dependes on device resolution… Maybe there is some macro to transform them?


Have you tried sprite->setTextureRect(CC_RECT_PIXELS_TO_POINTS(CCRect(0, 0, width, height))); ?