Thursday, January 28, 2016

On the Road to HaxeFlixel Scrollbars

I found out that scrolling how I would like it is fairly feasible using a FlxCamera derivative.  If I just update .scroll (rather than calling .setPosition() as I had initially thought) I can control the camera how I envisioned in this class. It so far doesn't do much beyond a basic FlxCamera, but will hopefully soon have scrollbar-drawing and mouse-handling code.
package flixel.ui;

import flixel.FlxCamera;
import flixel.math.FlxRect;

* An area of the screen that has automatic scrollbars, if needed.
* @author Gimmicky Apps
class FlxScrollableArea extends FlxCamera
* Creates a specialized FlxCamera that can be added to FlxG.cameras.
* @param ViewPort the area on the screen, in absolute pixels, that will show content.
* @param Content the area (probably off-screen) to be viewed in ViewPort
public function new(ViewPort:FlxRect, Content:FlxRect)
super( ViewPort.x ), ViewPort.y ), ViewPort.width ), ViewPort.height ),
1 );
_bounds = Content;
scroll.x = Content.x;
scroll.y = Content.y;
I was thinking of trying FlxSliders for the scrollbars, but visually I don't think they fit well. That's OK, a basic scrollbar will not be hard to draw. :)

No comments:

Post a Comment