I am developing a prototype for a game in Flixel in which a character floats upward continually to traverse the level. I would like to have a "tall" layout for levels and set the FlxG.camera to follow the character as he floats upward. My issue is in understanding the proper use of FlxG.camera. I have my game constructor coded as follows:
package
{
import flash.display.Sprite;
import org.flixel.*;
[SWF(width="640",height="480",backgroundColor="#000000")]
public class MyGame extends FlxGame
{
public function MyGame()
{
super(320,240,PlayState,2);
forceDebugger = true;
}
}
}
In the override of create() in the PlayState.as file I attempt to set the camera to follow the player as follows:
public var TheClimber:BalloonHero;
override public function create():void
{
/*set background color*/
FlxG.bgColor = FlxG.BLUE;
/*Set data for player*/
TheClimber = new BalloonHero(FlxG.width/2-5,480);
/*Add camera and set it to follow The Climber*/
//which will automatically set the boundaries of the world.
FlxG.camera.setBounds(0,1280,640,1280,true);
FlxG.camera.follow(TheClimber,FlxCamera.STYLE_PLATFORMER);
/*add player to the game*/
add(TheClimber);
}
I assumed this would set the camera bounds to twice the height of the SWF background(i.e. the FlxG height) and then scroll the background along with the specified FlxObject(TheClimber in this case) until it had reached the height of the game. However, I must be going about it incorrectly because when the zoom is 2 and the game height 720 the camera starts at the top of the screen with the player character not visible at the bottom of the game height. Is there a way to start with the camera/game focused on the bottom of the game object(FlxG.height) ? Or am I going about this the wrong way and have other issues with the way I am using the camera? Thanks in advance.