Flixel Forums

development => help => Topic started by: dimmduh on Tue, Nov 20, 2012

Title: Flixel Air Android perfomance
Post by: dimmduh on Tue, Nov 20, 2012
I created empty project (AS3 Air 3.1 project by Flash Develop), added flixel library, write default code (just black screen).
Compile to apk and run on Samsung Galaxy Tab II

FlxG.mobile = true;
+air renderMode = cpu

But the fps is only 15.
What do I do wrong ?)
Title: Re: Flixel Air Android perfomance
Post by: Esti on Wed, Nov 21, 2012
probably the resolution. Try a lower one and x2 and x3 scaling modes. Also, try GPU mode.
Title: Re: Flixel Air Android perfomance
Post by: dimmduh on Wed, Nov 21, 2012
Thanks!
the problem is in resolution

I spent a lot of time on experiments and found the best "solution" is
400x240  + x2 flixel scale + air scale mode + gpu mode  =  30 fps

but it looks really pixellate)
Title: Re: Flixel Air Android perfomance
Post by: grisevg on Thu, Nov 22, 2012
I'm currently trying to make my flixel game work on android. Can you please explain how to stretch game, so it would work on all resolutions?
PS: You might want to take a look at Axel http://axgl.org/ for better performance on mobile platforms.
Title: Re: Flixel Air Android perfomance
Post by: wg/funstorm on Thu, Nov 22, 2012
Can you please explain how to stretch game, so it would work on all resolutions?

I'm not familiar with flixel on Android, but in general you can change the scale mode flash used by the stage in FlxGame and FlxPreloader (do a search for scalemode).
Title: Re: Flixel Air Android perfomance
Post by: grisevg on Thu, Nov 22, 2012
Thanks! Found great article describing how to do it http://www.adobe.com/devnet/air/articles/multiple-screen-sizes.html
Title: Re: Flixel Air Android perfomance
Post by: mrfoos on Mon, Nov 26, 2012
I'll state that I'm no pro at flixel or android.  However I tried a simple game via Flixel Air Android I had made and after only about 30 or so chasing sprites it was too slow to play.  I tried everything I could think of.  I moved to the Flixel-Android (java) project.  I haven't converted everything yet but so far it seems MUCH faster.  I shall see as I progress.
Title: Re: Flixel Air Android perfomance
Post by: Esti on Tue, Nov 27, 2012
If you use alphas , scaling or rotation with air you are doomed
Title: Re: Flixel Air Android perfomance
Post by: grisevg on Sun, Dec 9, 2012
Is it possible to get descent performance with Flixel on Mobile Air?
I use resolution 327x160 with x3 zoom. No scaling or rotation and I use pngs for all the sprites and tiles.
Even on Nexus 7 performance is horrible - around 10 FPS.

Is there any good solutions to speed up things?
The only mobile device I've managed to get a good performance, was Samsun Galaxy SIII - it ran full 60FPS on it!.
Which is strange, I didn't thought difference between Nexus 7 and Galaxy SIII would be so big.

I've checked - Nexus 7 cpu is 1.3Ghz quad-core and S3 is 1.4Ghz quad-core... Difference is not so big...
Did anyone had a success of having Flixel game to work fine on modern mobile devices?
Title: Re: Flixel Air Android perfomance
Post by: Esti on Sun, Dec 9, 2012
Strange. I only tested on my iPod 4g so I can't know for sure but the best you can do for optimizing things is:

- Make sure you're using the last Air Mobile version (3.5) in your FlashDevelop project. It should say the number in the XML application file.
- Put -swf-version=16 in the project compiler aditional options to use the latest flash version
- In the air app properties select GPU render mode, in my iPod is a lot faster.
- Find a balance between resolution and scale. In my case I use 480, 320 x 2
- Cap the FPS at 30 "super(480, 320, PlayState , 2, 30, 30);"
- Make sure you're compiling in release mode and using the "normal" mode when packaging the app in android , or "slow test" in iOS.

Also, how are you checking the fps?, because if you open the console you are destroying your fps. Are you using tilemaps?
Title: Re: Flixel Air Android perfomance
Post by: grisevg on Mon, Dec 10, 2012
Strange. I only tested on my iPod 4g so I can't know for sure but the best you can do for optimizing things is:

- Make sure you're using the last Air Mobile version (3.5) in your FlashDevelop project. It should say the number in the XML application file.
- Put -swf-version=16 in the project compiler aditional options to use the latest flash version
- In the air app properties select GPU render mode, in my iPod is a lot faster.
- Find a balance between resolution and scale. In my case I use 480, 320 x 2
- Cap the FPS at 30 "super(480, 320, PlayState , 2, 30, 30);"
- Make sure you're compiling in release mode and using the "normal" mode when packaging the app in android , or "slow test" in iOS.

Also, how are you checking the fps?, because if you open the console you are destroying your fps. Are you using tilemaps?

Thanks a lot! "gpu" render mode really really helped. "direct" is not bad either, though a bit slower.
I wasn't really seeing any FPS, I just played this game so much, I can guess what FPS is pretty accurately...

The only problem is that in "gpu" mode everything is very blurry. As far as I understand, this is because in GPU mode, AIR will always smooth bitmaps on scaling.
Is there any workarounds for it, except using "direct" mode? Tried to google it, but didn't find any solution.
Title: Re: Flixel Air Android perfomance
Post by: Esti on Mon, Dec 10, 2012
That happened to me also but I found out that using an x2 scale the blur isn't noticeable. In consecuence you have to use bigger sprites that may slow down the game if are a lot. In my case my game was running at 60 fps still with big sprites but I prefered to cap the game at 30 to keep some space for having a lot of stuff going on.

About a real solution, I think the blur is caused because flixel uses blitting and I don't think is fixable, I was going to try Axel till I found out about GPU mode.
Title: Re: Flixel Air Android perfomance
Post by: Faceless on Wed, Dec 19, 2012
Small suggestion, if you're using AIR 3 include
Code: [Select]
<colorDepth>16</colorDepth> in the manifest, if you don't already, it will add a little bit of speed at the cost of using less of the color pallet. Though on mobile screens the difference is really negligible anyway. There is also absolutely no way to stop the blurring issue short of halving your speed or using CPU mode.

Also, depending on how far you are into the project you might look into using ND2D (https://github.com/nulldesign/nd2d) as an graphics library instead of Flixel. It'll get better performance on AIR than Flixel due to how it renders objects.
Title: Re: Flixel Air Android perfomance
Post by: paala on Wed, Mar 20, 2013
I tested myself, and it works very nice but has some limitation of resolution as the above posts state.
So if you cannot use  resolution higher than 400x240, which means that you must have zoom x2 .
One question. How do you add touch spites to control your char?
for example in this game: https://play.google.com/store/apps/details?id=air.de.codinsoft.littleRoboRunFree&hl=en (https://play.google.com/store/apps/details?id=air.de.codinsoft.littleRoboRunFree&hl=en)
You cannot add just a sprite - button if mouse is pressed do something, because you must press 2 sprites at the same time..

Title: Re: Flixel Air Android perfomance
Post by: Gama11 on Thu, Mar 28, 2013
You cannot add just a sprite - button if mouse is pressed do something, because you must press 2 sprites at the same time..

What you're talking about is called Multitouch. Flixel doesn't have that feature built-in, as that wouldn't make any sense on a PC. Flixel-Android (http://forums.flixel.org/index.php/topic,5432.0.html) seems to have that feature, and even supports up to 10 touches. Here's  (http://forums.flixel.org/index.php?topic=5472.0)another thread concerning Multitouch, maybe it helps.