Thank you for visiting the BlackBerry Support Community Forums.
BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)
BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.
"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."
- Kevin Michaluk, Founder, CrackBerry.com
Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.
07-23-2011 09:07 PM
The current version of my game on the app market has a problem with low framerates. I've investigated, and have determined that the speed issues are caused by drawing stacked objects. Removing the background image resolved the issue on all levels except for those containing a sprite object that contains three shape objects which draw low opacity circles on top of each other. Having that sprite object only draw one circle at a time fixed the speed on those levels as well.
So the long and short if it is that performance seems to suffer greatly from drawing objects in a hierarchy. Is there any way to have a background image without losing so much performance? Thanks.
Solved! Go to Solution.
07-24-2011 03:29 AM
The only way I have found to get decent framerates is using GPU rendering. Are you currently using CPU or GPU rendering? There are a number of drawbacks, but you will most likely see some good results by switching and optimizing your code a bit. Keep in mind, especially when using cacheAsBitcmap, that optimizations for the CPU won't necessary help when rendering using the GPU.
I have a scene with a moving background and 150-160 partially transparent sprites which are also moving. As well, the stage is listening for touch events. with GPU rendering, I can hold a steady 45-50 FPS, when I would get about 20 FPS on the CPU. Especially with the moving background, the whole screen must be redrawn every frame, and the CPU doesn't have the horsepower to keep up.
07-24-2011 09:10 AM - edited 07-24-2011 09:11 AM
You could use blitting the images instead of a hierarchy, which is apparently a lot faster because only one object is added to the stage. You can find some great tutorials on this at http://gotoandlearn.com/:
Playbook App: Car Crash
07-24-2011 09:32 PM
Just to clarify, is this the correct way to enable GPU rendering?
<?xml version="1.0" encoding="UTF-8"?> <qnx> <initialWindow> <systemChrome>none</systemChrome> <transparent>false</transparent> <renderMode>gpu</renderMode> </initialWindow> <author>daAutha</author> <authorId>daID</authorId> <publisher>daPublisha</publisher> <category>core.games</category> <splashscreen>daSplash.png</splashscreen> </qnx>
As for blitting, I've been hoping to avoid it, since it seems like alot of work for a negligible benefit (a background image) in this game, but I'll check it out. I just can't believe the PlayBook can't handle a handful of separate objects. I'll post back later.
07-24-2011 10:54 PM
Joe, you should put it under your AppName-app.xml file, like so:
<initialWindow> <content>Whatever.swf</content> <autoOrients>false</autoOrients> <aspectRatio>landscape</aspectRatio> <renderMode>gpu</renderMode>
Make sure you have the right captialization as well.
07-24-2011 11:05 PM
From your other post I remember that you have an effect with a ring that scales up. Unfortunately scaling is not supported with the GPU right now. Basically objects that move only (no rotation, scaling, or shape-changing) are well-accelerated. I'm sure it's still worth trying, but don't be too surprised if you don't notice a difference.
I do think that the GPU would help with your background image, though. I haven't checked what the max image size is for the PlayBook GPU, but if it's still slow you could try splitting it up into 4 sections or so and adding those all to the display hierarchy as usual.
Perhaps the best way to understand what is accelerated on the GPU at the present time is to look through what you can do with a BitmapData object and what the limitations are, and that seems to correspond pretty well with what the GPU can do. This may change in the future, though, since the typical GPU can do a lot more than what is available in flash.
07-25-2011 12:36 AM
Aw, ****in'... putting it under [AppName]-app.xml sure made a difference! Well...I can put my background and layered "waves" back in without losing significant frames now. That's awesome. Strange, though...it seems to have a hiccup every so many seconds. Could garbage collection do that if I'm creating and destroying lots of objects?
The only thing of note is that one gradient filled line isn't displaying properly anymore. Certainly not a dealbreaker, just an interesting bug to note. All other gradient fills look good so far. I'll check it out tomorrow and let you know what I find. Thanks again, I had a feeling I should mention the name of the file I was putting the gpu tag in.
07-25-2011 01:44 AM
Yeah, garbage collection is by far the most likely culprit for occasional stuttering in a game. I'd suggest creating a pool of objects ahead of time and reusing them. There are lots of examples out there for how to do this, and here's one such example: http://lab.polygonal.de/2008/06/18/using-object-po
07-25-2011 08:18 PM
@GoldenJoe, Glad to here you got your framerate up. It sounds like you are using the drawing API's correct? lineTo, drawRect etc...
Well even with cacheAsBitmap and cacheAsBitmapMatrix you may see some slow downs. The drawing API can be slow, even in GPU mode, and Adobe advises against it for moblie. I would try to use PNG images if you can to see if that makes a difference at all.