Skip to content

Instantly share code, notes, and snippets.

@videlais
Created November 6, 2013 05:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save videlais/7331419 to your computer and use it in GitHub Desktop.
Save videlais/7331419 to your computer and use it in GitHub Desktop.
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