Showing posts with label flex. Show all posts
Showing posts with label flex. Show all posts

Saturday, June 18, 2011

HD Progress

The Rainstorm has now been converted to HD foreground graphics, with low-res water effects and background.  With the water effect as such low resolution (1/4 size) as it is to get good framerates, it looks pretty awful compared to what it was (1/2 size).

I decided that it's better to have a crummy visual effect with better gameplay than the opposite.  The only way I think I can get good performance out of this game (mostly the water effect) is to convert to C++/OpenGL once the PlayBook native SDK is released.  And I do want to do that.  One of my coworkers today had a great idea to make the game more fun, but it will be a lot of work.  I might just have to save the idea until I port it to C++/OpenGL.  Of course, there are other games I want to do in 3D...

I previously mentioned how I got high-quality foreground graphics with low-quality background, and yesterday I thought of  a much simpler and probably faster way to do it, so refactoring was much less of a headache.  In short, the app now runs at full resolution, including all of the foreground bitmaps and such (no scaling down),  and the background is rendered at low resolution and upscaled.  That way only one thing needs to be scaled, rather than a whole bunch of things.

Tuesday, June 07, 2011

The Rainstorm now supports multi-touch

After just 40 minutes of work, The Rainstorm now supports multi-touch, and it's pretty sweet.  The Air documentation is very good, with the examples especially.  The one downside is that I don't get mouse events now, so I need to figure out how to bring those back (while also keeping multi-touch) so I can continue to develop without having to test on the physical device every time.

For the developers here, this is the Air documentation page that is most useful:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/events/TouchEvent.html

Saturday, June 04, 2011

How to get high-res images in a low-res Air app

I thought about another way I might get partial HD graphics working.  The problem is that the resolution of the screen is 1024x600, and setting the application to that size (even without changing the assets) slows things down too far.  So I set it to 512x300 and then let Air scale it to full res to get reasonable performance.  This means everything is pixelated doubly.

After noticing that text and standard buttons render at full HD, I had the thought of loading a bitmap that's double the resolution that it needs to be, then scaling it down before letting Air render it.  This works for the one item I tested it on.  Some of my other objects use a different method for rendering, so those will take some work to HD-ify.  Here's what the code looks like:


// This image is double the size it needs to be
[Embed(source='rainStormTitleFinalHD.png')] public static var RainStormTitleImage:Class;
titleImage = new Image();
titleImage.setImage(new RainStormTitleImage);
titleImage.x = -30;
titleImage.y = 10;

// This part is where we scale it down.
titleImage.scaleX = 0.5;
titleImage.scaleY = 0.5;

addChild(titleImage);
The result of this is that when an Air app designed for 512x300 is upscaled to 1024x600, the above image is the perfect resolution (not pixelated).

Here is a comparison of a section of the screen.






First the original, pixelated image.










And here's the HD image.

So it's clearly working, and so far it doesn't affect the framerate noticeably.  But it's only the title screen that's setup this way.

Unfortunately, most of my game objects use BitmapData and copyPixels to an off-screen buffer which is eventually rendered in the normal Air way.  Before GPU acceleration in Air, this was a speedy way of drawing graphics that don't need to be scaled or rotated.  With GPU acceleration, this way is slower.  So I need to make everything a Sprite or some such and just do things with the "normal" Air method to get HD bitmaps in a low-res app.  And that's a fair bit of work.  But right now it's not my highest priority.