SpriteFrameCache and ContentScaleFactor

v3.17.2

Hello guys, this was probably asked a lot of times but i can’t figure it out. i’m loading some file*.png to spriteframecache like this:

auto sprFrame = SpriteFrame::create(path, Rect(startX, startY, width, height));
spriteFrameCache->addSpriteFrame(sprFrame, "someName");

the thing is this images are like this: (some google image)
image

and the sprFrame is loading some part of the other frame.

i’m guessing that in some place this files are being modified by the contentScaleFactor, but not in my code. and i dont know where and i dont know how to apply the scale to the frame.

i’d tried to * + - the contentscalefactor to the startX, Y, width height, but im getting worse results.

thanks for any help.

edit:: its something related to

CC_RECT_POINTS_TO_PIXELS in

line 93 of CCSpriteFrame.cpp

Is there a reason you aren’t using a Texture Packing tool such as Zwoptex, or TexturePacker etc that outputs a .plist along with the image file? Cocos handles the rest automatically if you have an accompanying plist/data file…

Yes, there is a reason.

I solved that problem by just doing the oposite of what this macro is doing

, (wich idk why converts to scaled pixels a file that is not yet part of the game)

with this:

float csf = cocos2d::Director::getInstance()->getContentScaleFactor();
auto sprFrame = SpriteFrame::create(path, Rect(startX / csf, startY / csf, width / csf, height / csf));
spriteFrameCache->addSpriteFrame(sprFrame, "someName");

That solves only that problem. And i cant find docs talking about content scale factor in details. idk what is happening under the hood, for example: if a scale a TMX map then the sprites i add as child moves different in different resolutions.

for eg: do i need to scale actions like move by?

if you have any docs i will appreciate it.