Header bar and FlxCamera?

20 views
Skip to first unread message

Thomas Bernard

unread,
Jul 27, 2015, 12:15:08 PM7/27/15
to HaxeFlixel
I want to have an FlxState with a fixed header bar and a scrolling body content. The problem is that, when I scroll the body, it displays below the transparent header bar (see screenshots). 
So I am looking for a solution that would allow me to not display part of the body that is below the header bar and should be "masked" by it.
I thought to use a FlxCamera positionned just below the header bar and that would follow the body but I couldn't make it work properly.
Actually, I have multiple issues.
First, the FlxCamera positionning seems to be bugged. Indeed, If I create a camera with

new FlxCamera(0, header_height, FlxG.width, FlxG.height-header_height);

the camera is not positionned at header_height on the y axis as it should be but is at header_height/2 as the camera seems to be automatically centered vertically...
So I have to create it with:

new FlxCamera(0, header_height*2, FlxG.width, FlxG.height-header_height);

to have it correctly positionned just under my header bar...


The second issue is that if I do:

mycamera.follow(body); //body beeing an FlxSpriteGroup of my levels items that is drawn outside of the screen (positionned at (FlG.width,0) )


the camera center on the center of the body object rather than aligning top left corners. So how to tell the camera that its top left corner should match the top left corner of the body object at start?
And then, how can I make my body to scroll inside the mycamera area? 
Because when I do 

mycamera.scroll.y = value;

nothing is happening; I always have the same region of my body object displayed in the mycamera region...


Any help would be highly appreciated ;)

Screenshot_2015-07-27-17-16-30[1].jpg
Screenshot_2015-07-27-17-16-39[1].jpg
Reply all
Reply to author
Forward
0 new messages