Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Reply
Contributor
ObsidianX
Posts: 13
Registered: ‎03-26-2011
My Device: None
My Carrier: None

Maximum Sprites on Stage

Hey folks,

 

I'm trying to write a Solitaire game but the playbook slows to a complete crawl when its running.  I believe I've narrowed it down to the number of sprites on stage at any one time (after the game is delt there are at least 28 cards on the table)

 

Are there any common Gotcha's that I can be looking out for to try and optimize this for the PlayBook?  The game has been running perfectly on my desktop during development so running it on the device for the first time came as a huge shock.

Please use plain text.
New Developer
Dangazak
Posts: 7
Registered: ‎03-30-2011
My Device: PlayBook tablet
My Carrier: none

Re: Maximum Sprites on Stage

I think that the maximum number of sprites on stage depends on the sprites size, animation(scale and rotation of bitmaps is expensive), alpha...

I recomend you to read this, it will definetly help with your problems.

Please use plain text.
Contributor
becooltim
Posts: 25
Registered: ‎03-19-2011
My Device: BlackBerry Bold 9930 & PlayBook
My Carrier: Sprint

Re: Maximum Sprites on Stage

Are you using cacheAsBitmap? It may help performance as long as the only changes that are made to the sprites are moving them via their x and y properties. cacheAsBitmap use a lot more memory.
Please use plain text.
Contributor
ThomasOnWeb
Posts: 21
Registered: ‎04-25-2011
My Device: Playbook
My Carrier: NaN

Re: Maximum Sprites on Stage

Indeed, Vector based graphics make your app lagg a lot more. This is not only on the Playbook but on android devices as well if you are using Adobe AIR. A known performance boost is like becooltim says is to cache your sprites as bitmaps.

 

 

sprite.cacheAsBitmap = true;

or

movieclip.cacheAsBitmap = true;

 

It is also know to specify a new matrix a long with that but can't remember exactly how that worked

----
Playbook Apps: Notes
Please use plain text.
Contributor
Munsie
Posts: 23
Registered: ‎04-27-2011
My Device: PlayBook Developer
My Carrier: n/a

Re: Maximum Sprites on Stage

Flash performance on a typical desktop is much better than the Playbook, for now. Things might get better in the future. The simulator at least on my kit, is still not accurate enough to benchmark. That was driving me nuts, so now I don't even use the simulator, just deploy on my device for benchmarking, etc. And yah....the performance isn't that great, but if you can try to make it run at stable speed instead of letting it slow down / speed up, etc, etc. I think that works better in my opinion, unless you're using a decent time based solution.

Please use plain text.
Developer
TheDarkIn1978
Posts: 409
Registered: ‎12-10-2010
My Device: PlayBook
My Carrier: N/A

Re: Maximum Sprites on Stage

 


ThomasOnWeb wrote:

 

It is also know to specify a new matrix a long with that but can't remember exactly how that worked


cacheAsBitmapMatrix

 


PlayBook Applications:
Drop Swatch
Please use plain text.
Contributor
ThomasOnWeb
Posts: 21
Registered: ‎04-25-2011
My Device: Playbook
My Carrier: NaN

Re: Maximum Sprites on Stage

Exactly
----
Playbook Apps: Notes
Please use plain text.
Developer
cycletronic
Posts: 113
Registered: ‎03-23-2011
My Device: Playbook, Z10
My Carrier: Platinumtel

Re: Maximum Sprites on Stage

If you really want to optimize, you can do away with Sprites altogether and just use BitmapData and its copyPixels method.  You have to give up lots of features (rotation, scaling), but it's quite fast.  It's the technique I use for my game, "The Rainstorm" (http://appworld.blackberry.com/webstore/content/35668?lang=en).  Here's a link to a series of tutorials that uses the technique: http://www.brighthub.com/internet/web-development/articles/11010.aspx

It's still not totally optimized code, but it does use the copyPixels idea.

 

Someone reported about 20fps, and I use more than 20 "sprites", plus filters.  

----------------
WIP game: Melodaeum
My graphically bland but very useful Morse Code trainer: Speed CW
My graphically attractive but boring game: The Rainstorm
Please use plain text.
Contributor
Munsie
Posts: 23
Registered: ‎04-27-2011
My Device: PlayBook Developer
My Carrier: n/a

Re: Maximum Sprites on Stage

Actually, with GPU rendering turned on, I'm getting good results using stage sprites. :smileyhappy:

Please use plain text.