FP and MovieClip layer problem[SOLVED]


(billy2000) #1

So i have a movieclip(our logo),and i want to make a image fade over it.But i don’t know how to set my image layer to be lower than the movieclip layer.U guys know any awesome function/method i don’t know about that can help me here? XD ty


(Justin Wolf) #2

MovieClips are not apart of the FlashPunk graphic hierarchy. So they will always appear in front of everything that FlashPunk renders. A way around this is using FP.buffer.draw(), albeit it’s a very expensive method to use. I imagine you’ll be okay using it as it’s just your logo and likely only going to be displayed on menus and not during actual gameplay!

Inside your Logo’s Entity:

private var mMatrix:Matrix = new Matrix();
private var mSprite:MovieClip = new MovieClip();

override public function render():void 
{
	super.render();
		
	// draw movieclip
	mMatrix.tx = x - FP.camera.x;
	mMatrix.ty = y - FP.camera.y;
	mMatrix.a = mSprite.scaleX, mMatrix.d = mSprite.scaleY;
	FP.buffer.draw(mSprite, mMatrix);
}

Using the render() loop to draw the MovieClip will utilize whatever layer that Entity is set as. Again, this is a costly way to utilize MovieClips with the FlashPunk layering system (but the only way I know of doing so), so use sparingly!


(billy2000) #3

Oh ty .I have a world that just make logos appear and go to tittle screen world after .I think it shouldn’t affect that much in my situation .THX for the code :smile: