Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ActionScript 3 Multi-camera HUD example
package
{
import org.flixel.*;
public class PlayState extends FlxState
{
private var hud:FlxGroup;
private var world:FlxTilemap;
private var player:PlayerSprite;
//
// Add additional variables
//
public function PlayState()
{
}
override public function create():void
{
//
// Add instantiation of variables
//
FlxG.worldBounds = new FlxRect(0, 0, world.width, world.height);
FlxG.camera.setBounds(0, 32, world.width, world.height, true);
FlxG.camera.follow(player, FlxCamera.STYLE_TOPDOWN_TIGHT);
player.cameras = new Array(FlxG.camera);
var hudCamera:FlxCamera = new FlxCamera(0, 0, FlxG.width, 32, 0);
hud = new FlxGroup();
//
// Add all HUD elements like a background or text details
//
hud.setAll("cameras", new Array(hudCamera), true);
add(hud);
FlxG.addCamera(hudCamera);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.