Created
November 6, 2013 05:32
-
-
Save videlais/7331419 to your computer and use it in GitHub Desktop.
ActionScript 3 Multi-camera HUD example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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