What does "trimmed" mean wrt SpriteFrame?

The SpriteFrame documentation mentions this several times. For example,

create()
Create a SpriteFrame with a texture filename, rect in points. It is assumed that the frame was not trimmed.

getOriginalSizeInPixels(void)
get original size of the trimmed image

What does it mean?

In particular, if I created a spritesheet with TexturePacker from a bunch of images, and then loaded it by calling SpriteFrameCache::getInstance()->addSpriteFramesWithFile(“Images.plist”), will getOriginalSizeInPixels() give me the original size of the corresponding image, or some other (smaller?) number depending on how it decided to trim the image?

Thanks!

Aleksander

1 Like

TexturePacker allows trimming the excess whitespace around the individual image files.
Check see visual example of “Trimming / Cropping” section of https://www.codeandweb.com/texturepacker

Basically if your sprite frames are, for example, 100x100 .png images, and TexturePacker trims them down to a 60x40 size then _originalSize is 100x100 and _rect is {Vec2_offset, 60x40}.

Cocos2d uses the original size in various cases in order to calculate the vertex coordinates offset, among possibly other values, of the given sprite.

If you want o know further detail consider reading through CCSprite.cpp with a note on methods setSpriteFrame, setVertexCoords, updateStretchFactor (if QUAD block).

2 Likes

Thank you, I think I get it.