Layers between FP.stage chield and a entity from the world[SOLVED]


(billy2000) #1

Hyas. For some reasons i had to add a sprite to the FP.stage using:

FP.stage.addChild(_Sprite);

But i would like my cursor sprite to be over it.

What can i do to make this,because right now the sprite its over every entity in my world.


(Ultima2876) #2

What do you need to add that sprite to the stage for?

Anyway, the best way to get it layering nicely with FlashPunk is to get the sprite as a bitmapData and create a FlashPunk Image of it. However, this will disable any additional Flash functionality that the sprite has (mouse clicks, event handling etc) so you’ll have to redo any of that stuff yourself.

var bitmapData: BitmapData = new BitmapData(_Sprite.width, _Sprite.height, true, 0);
bitmapData.draw(_Sprite);

var myImage: Image = new Image(bitmapData);
FP.world.addGraphic(myImage);

Something like that.


(billy2000) #3

Well i need it as a sprite because it looks bad otherwise (because of scales),but ill try to do exactly the opposite of what you told me. Instead of working on the sprite ,ill work on mouse cursor and add it to the stage also ,so that it can be over my sprite.


(billy2000) #4

Aaaaaand it worked . :smile: Ty very much for the idea :smiley:


(Ultima2876) #5

Did you try setting the smooth property of Image to true? That smooths out scaling and rotation and makes it look much nicer., while being much faster to render than a native Flash Sprite (blitting is faster, which is why FlaskPunk uses it extensively!).


(billy2000) #6

Thx for the idea,no i did not ,i didn’t even knew about it actually… Thx again ^^.