mirzahat
mirzahat

Reputation: 1025

cocos2d zooming sprite without distortion?

I want to implement zooming of sprites with a pinch gesture in Cocos2d.

How do I achieve it without the image getting pixelated?

I tried with vectors but with no success, I'm doomed using raster bitmap images.

  1. Do I need the largest possible image with the highest resolution to make it look nice?

  2. What is the size limit for pngs in cocos2d?

  3. What other pitfalls do I need to consider?

Upvotes: 1

Views: 435

Answers (1)

CodeSmile
CodeSmile

Reputation: 64477

  1. Yes. For example if the sprite should cover an area of 1024x1024 pixels when zoomed in to maximum, you need to create the image as 1024x1024 and set the scale property to below 1 in order to create a smaller version. If you use scale greater than 1.0 the image will always lose detail and become ever more blurred as scale increases.

  2. There is no size limit in cocos2d, it's the devices that impose the limit. Most devices can handle 2048x2048 except 1st and 2nd generation which support only 1024x1024. You wouldn't normally support these older devices though, so 2048x2048 should be the default. Several newer devices (iPad 2+, iPhone 4S+) can use up to 4096x4096 textures.

  3. Memory consumption. Not sure what you're trying to do, but often developers have little understanding about how much memory textures consume and what amount of memory is available. For instance, 2048x2048 as PNG with 32-Bit color consumes 16 MB of memory. Don't plan on using more than 4-5 of these, unless you're able to reduce color bit depth and use TexturePacker to be able to use the compressed .pvr.ccz format. Read my article about optimizing memory usage for more info.

Upvotes: 2

Related Questions