views:

41

answers:

2

I have never seen this issue before, its very strange. Just wondering if anyone else has come across this too.

alt text

I have added a sprite to my game, its supposed to be the top left corner of a box to put text on to. I want to make it scalable without loosing anything so i have it broken up into sections. In the image above the one on top is the image itself, and then the one on the bottom is the image when its being drawn in the iPhone simulator.

Any idea why the last column of pixels on the right are altered? I have not scaled the image at all.

+2  A: 

I don't know about Cocos2D, but in general terms what you've done here is to draw the image at a position that isn't an exact multiple of one pixel.

Consequently even without scaling you have resampled the image across a grid that doesn't coincide with the original image data, causing all pixels to be a bit off. It's just the right-hand edge is the most obvious case, since the resampling leaves you with a partial transparency here. But look at eg the two rows of purple pixels in the border: they're not the same, because your vertical alignment is off as well, causing a small amount of colour from the grey border below it to bleed into the lower row of purple.

bobince
Exactly, heard that today in a presentation. Either way, since this only affects Simulator and not the device, one can just ignore those artifacts.
GamingHorror
Really, is the simulator itself misaligning drawn objects? That'd be pretty dodgy!
bobince
+1  A: 

Ok I actually figured it out this time. Cocos2D adds a bit of antialiasing to CCTextures. To stop it from doing this you need to call this:

[[mySprite texture] setAliasTexParameters];

to turn it back on you call this:

[[mySprite texture] setAntiAliasTexParameters];

Tiddly