You can set a FlxCamera
to follow a FlxObject
. This will allow your camera to scroll as the object moves.
There are 6 built-in styles for FlxCameraFollowStyle
, although you are free to set your own deadzone
, if you wish.
// tell the camera to follow sprite with the LOCKON style
FlxG.camera.follow(sprite, FlxCameraFollowStyle.LOCKON);