Search code examples
iphonecocos2d-iphonescaleblurccsprite

Zooming in on pixel art in Cocos2D causes blur- iPhone


When a CCSprite of mine, which uses a 16x16 image, is scaled up, there is a lot of blurring.

This image is pixel art, and therefore meant to be pixelated, but not blurred.

I've tried running the method setAntiAliasTexParameters on the texture of the sprite, but it doesn't change anything.

Here is the code: (mainSprite is CCSprite and slide1 is CCTexture2D)

slide1 = [[CCTexture2D alloc] initWithImage:[UIImage imageNamed:@"slide1.png"]];
[slide1 setAntiAliasTexParameters];

[mainSprite setTexture:slide1];

Thank you, any help is appreciated!


Solution

  • You should use this instead:

    [slide1 setAliasTexParameters];
    

    this will tell your sprite not to anti-alias, preserving the pixelated look

    (using cocos2d v2.0 -- not sure if this works in previous versions)