eilas
eilas

Reputation: 392

Cocos2d downscaling image

When I have two sets of images - usual set and set for Retina display, Cocos2d automatically chooses which of them to use. If there is no Retina image, usual image is scaled for using at Retina display. How can I do vice versa? I have Retina image and want to downscale it, when there is no usual image.

Upvotes: 1

Views: 134

Answers (2)

Lorenzo Linarducci
Lorenzo Linarducci

Reputation: 541

CCSprite *item;

if(CC_CONTENT_SCALE_FACTOR() == 1)
{
    item.scale = 0.5f
}

Upvotes: 0

CodeSmile
CodeSmile

Reputation: 64477

You shouldn't. Simply create the downscaled (non-Retina) image in a drawing program or image editor/converter and add it to your project.

Rationale: Retina textures use 4x as much memory as their SD counterparts. At the same time non-Retina devices have less memory and less horsepower. Downscaling on the fly sacrifices memory and performance, and requires extra code to perform the downscale. It's wasteful and inconvenient at the same time: don't do it.

The only benefit would be a slightly smaller bundle size, but there are better ways to cut down bundle sizes (pvr textures, decrease color depth, remove unused assets, texture atlases if you don't use them already, ....).

Upvotes: 1

Related Questions