Not sure if there is an easier way, but I would just do something like
CGFloat myDesiredWidth=50; CGFloat myDesiredHeight=70; CGFloat startWidth=mySprite.size.width; CGFloat startHeight=mySprite.size.height; CGFloat scaleX=myDesiredWidth/startWidth; CGFloat scaleY=myDesiredHeight/startHeight; CGFloat finalScale=MIN(scaleX,scaleY); mySprite.scale=finalScale;
Put this in a category on CCSprite and you wonβt have to worry about it anymore.
source share