how to set image as scale to fill,aspect fit,scale to fit etc properties?
how to set full image in rect as i don’t know how to make it
please reply fast
its urgent
Hi,
If I understand you correctly, then use this:
sprite->setScale(x / sprite->getContentSize().width, y / sprite->getContentSize().height);
Note that x and y is the size in pixels that you want your sprite to be. So if you have a layer of size 100, 100 and you want your sprite to be half the size on that layer, then scale the sprite accordingly:
sprite->setScale(50 / sprite->getContentSize().width, 50 / sprite->getContentSize().height);
Or better yet, for a general function use this:
sprite->setScale(parent->getContentSize().width * scale_modifier_x / sprite->getContentSize().width, parent->getContentSize().height * scale_modifier_y / sprite->getContentSize().height);
Hope this helps.