0

I'm making a game in AS3 with Adobe Flash Pro CC.

I've made a mobile version for Android but if I put GPU in render mode, my blurred effet or my glow effect doesn't work on the device.

If I put CPU or direct the blurred and glow effects are working but animations are not smooth. (with GPU render, everything is extra smooth !)

Do you know how I can have my blurred effect and my glow effect with GPU render mode ?

Thank you very much,

Stephan


Here's what I did (but it still doesn't work on an actual Android device) :

My code was :

private function itemGlow(isGlowing:Boolean):void{
                        if (isGlowing){
                                    var glow:GlowFilter = new GlowFilter();
                                    glow.color = 0xFFFF00;
                                    glow.alpha = .75;
                                    glow.blurX = 10;
                                    glow.blurY = 10;
                                    glow.quality = BitmapFilterQuality.MEDIUM;

                                    draggedItem.filters = [glow];
                        } else {
                                    draggedItem.filters = null;
                        }

And I replace it with this code :

public function itemGlow(isGlowing:Boolean):void{
                        if (isGlowing){
                                    var glow:Sprite = new Sprite();
glow.graphics.beginFill(0); // black color
glow.graphics.drawCircle(20, 20, 20);
glow.graphics.endFill();

draggedItem.filters = [new GlowFilter(0xFFFF00, 1)];

var bd:BitmapData = new BitmapData(50, 50, true, 0x00000000);
bd.draw(glow);

var glowbit:Bitmap = new Bitmap(bd);
addChild(glowbit);

                        } else {
                                    draggedItem.filters = null;
                        }

No errors, glow visible on the simulation device. But when it's not working on real Android device....

user2421975
  • 197
  • 1
  • 13

1 Answers1

1

Vector effects and blending modes won't work in GPU mode. If you want to get a glowEffect you will have to calculate it in memory but display a bitmap that has the effect.

Here is a minimalist example:

// creating a glowing sprite in memory
var glowingSprite:Sprite = new Sprite();
glowingSprite.graphics.beginFill(0); // black color
glowingSprite.graphics.drawCircle(20, 20, 20);
glowingSprite.graphics.endFill();
glowingSprite.filters = [new GlowFilter(0xFFFFFF, 1)];

var bd:BitmapData = new BitmapData(50, 50, true, 0x00000000); // when entering size, usually get the size from glowingSprite.getBounds(), it will return the size with the filter
bd.draw(glowingSprite);

var b:Bitmap = new Bitmap(bd);
addChild(b);

As you will see you can now work with filters and blend modes! If you want an animation, just create an array of bitmapData objects and in the bitmap object change the bitmapData property on each frame.

From Adobe:

The following limitations exist when using GPU rendering mode in AIR 2.5 and above:

  • Filters are not supported.

Source

Josh
  • 8,079
  • 3
  • 24
  • 49
Creative Magic
  • 3,143
  • 3
  • 28
  • 47
  • Ok. But it seems that "new GlowFiler(5, 5, 5)" isn't working... Error 1136: Incorrect number of arguments. Expected 0. Do you know why ? Cause they are important (not working without it) – user2421975 Jan 06 '14 at 09:08
  • sorry, was writing by memory. I edited, now it works – Creative Magic Jan 06 '14 at 09:10
  • Hmm weird. No errors, works great on the simulation device but still not working on my android device.. (don't see any glowing...) – user2421975 Jan 06 '14 at 09:23
  • Is the parent of your bitmap cached as bitmap. GPU development in Flash is almost based on having displayObjects cached as bitmap – Creative Magic Jan 06 '14 at 10:19
  • The bitmap doesn't really have one specific parent as the glowing is for every items in every scenes of the game.. – user2421975 Jan 06 '14 at 10:36