Draw anything in front of foreground?

Almakos

  • Posts: 632
Hi,
is it possible to have any actors appear on top of foreground?
I need parallax scrolling, but want some actors (like UI and HUD elements) appear on top of foreground. Is it  possible to achieve?
Thank you.
Fishing Fantasy Trailer


Hectate

  • *
  • Posts: 4645
I imagine that you would have to use code to draw the actor's BitmapData to the screen after everything else has been done. This is just a theory and completely untested.
:
:
Patience is a Virtue,
But Haste is my Life.
Proud member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.

camaleonyco

  • Posts: 204
I would love to know if you found a way to do this. I've been trying to do this but frankly my coding skills are lame. Making the foreground an actor with a parallax behavior could work, but that really hurts my game's performance. So, How can we draw actors in front of the foreground images?

PapaGrimbles

  • Posts: 49
I am also looking for how to achieve this. Any help would be awesome.

Bombini

  • *
  • Posts: 1385
hi guys,

is it necessary that you use a foreground for HUDs etc?
You could also create actors at "Front" (scene behaviour) and anchor them to the screen.

Not sure if i understood right

Cheers!

rob1221

  • *
  • Posts: 9472
For Flash you might do something like this (design mode):

(custom import)
import flash.display.Bitmap;
import flash.display.BitmapData;

(arbitrary code)
var object1Image:BitmapData;
var object1:Bitmap;

(when created)
[hide sprite for self]
object1Image = actor.currSprite.pixels.clone();
object1 = new Bitmap(object1Image);
FlxG.stage.addChild(object1);

I haven't tested this specific example, but I did something like it before to keep a button still during a slide transition.  If you need a moving object, I think that would require setting the X and Y of the Bitmap object.  For iOS I have no idea what the code is.

@Bombini they could, but as camaleonyco stated it's a performance drain.

camaleonyco

  • Posts: 204
Thanks a lot. Works perfectly for me. I think this is useful for UI actors, so I guess the bitmap shouldn't need to be moved. The only problem is that it appears on the top left corner, and that it stays after switching scenes, but that's easy to fix:

(when created)
[hide sprite for self]
object1Image = actor.currSprite.pixels.clone();
object1 = new Bitmap(object1Image);
FlxG.stage.addChild(object1);
object1.x=actor.getX();
object1.y=actor.getY();

(Exit Event)
FlxG.stage.removeChild (object1);

Thanks again!

irock

  • *
  • Posts: 2899
You know there's a "draw image for [actor]" block under Drawing, right? Does that not work?

camaleonyco

  • Posts: 204
You know there's a "draw image for [actor]" block under Drawing, right? Does that not work?
No, It doesn't.