0

In case you are familiar with the Flixel game engine, open sourced here: https://github.com/ericjohnson/canabalt-ios/tree/master/flixel-ios

How would you go about adding support for retina graphics? Like retina sized textures.

I tried adding @2x atlas pngs and they seem to load, however I guess the offsets will be incorrect as specified in the atlas plist. Changing the plist (load retina atlases for retina devices) with correct offsets surely loads the graphics correctly, but the textures themselves generally shows up too big, and other problems seem to occur.

Progress update:

  • As noted above I'm creating separate texture atlases for high res graphics - I guess this would mean I would need to have a complete set of high res graphics (or none at all) to make things simple. This makes the graphics load correctly (or the offsets are incorrect of course if using lowres atlas plist)

  • When creating FlxSprite:s, I don't use the shorthand static creators, but the init* constructors, specifying the modelScale parameter using the device's scale (will be 2.0 for retina devices, 1.0 for other). With this the graphics also show up with correct size on screen no matter retina screen or not.

What's left is make the retina versions use the correct resolution because somewhere the texture itself seems shrunk, then sized up again producing a blurry, incorrect effect - not the original high res image. I'm guessing the last culprit is somewhere in SemiSecretTexture class...

Progress update again:

  • I was likely just wrong above. I think I found out how to do it. No need to set modelScale to 2.0... I might sort out the details and provide the answer later :-)
Jonny
  • 15,955
  • 18
  • 111
  • 232
  • Just for the record, Flixel is by Adam "Atomic" Saltsman, and the source is at https://github.com/AdamAtomic/flixel – Mar May 08 '12 at 04:38
  • By "retina" I assume you just mean "higher resolution". Retina is really just a buzzword for high resolution at smaller density. – Adam Harte May 08 '12 at 05:14
  • That link is for the Canabalt game, not the Flixel engine. This is what @mouseas is talking about. – Adam Harte May 08 '12 at 05:17
  • This is the iOS port (100% native) so I cut out the AS tag. Also I linked to the actual source up there. Sure the Canabalt game is in there too, as is the Flixel engine. – Jonny May 08 '12 at 06:59

1 Answers1

0

I guess there's no straight forward way to do this, but when you instantiate your class derived from FlxGame, don't use YES in the zoom parameter. For starters. Then you'll have to load different atlases for retina and non-retina. Not sure what happens with iPad support from there however. Then when loading textures for FlxSprites, you need to specify the "device scale", which would be 2.0 for retina devices - get it from [UIScreen scale]. This would make retina and non-retina work good for FlxSprite. Then FlxTileblock (and possibly other classes) is another story which I haven't solved yet.

Jonny
  • 15,955
  • 18
  • 111
  • 232