Saturn
Saturn

Reputation: 18149

What whappens when I don't provide the -hd file?

Cocos2d-iphone 1.0.1

I enable retina display for my app. I provide myimage.png,but I don't provide myimage-hd.png. When I run the game, I indeed get a message saying that the HD file was not found. Great. However, the game doesn't crash: I see in my game that there is the sprite apparently using the sd file.

What happened? Is it using the sd file and then resizing it? Is it still retina, but with a smaller version of my sprite?

Upvotes: 0

Views: 127

Answers (1)

CodeSmile
CodeSmile

Reputation: 64477

It will fall back to using the SD file. The SD file will be half the size as the HD version of the file would be if it had been supplied. So if you later add the -hd file you'll see a much larger version of the image. That's something you want to avoid.

It's generally not a good idea to support Retina only partially. If you use -hd then it's recommended to use it for all assets indiscriminately. The same goes of course for -ipad and -ipadhd.

Something that I learned the hard way today is if you supply only the -hd or -ipad version but don't include the regular version without the suffix, cocos2d will try to load the SD image (because that's what it always checks first). Since that fails cocos2d (v1.1) will return a nil texture instead of looking for the -hd or -ipad version. To fix this use CCFileUtils setIpadSuffix and setiPhoneRetinaSuffix to something other than -hd or -ipad. In my case it worked to just set them to the empty string (no suffix).

Upvotes: 1

Related Questions