To get the screen’s dimensions, use width
and height
. These are useful for positioning objects.
screenWidth = FlxG.width;
screenHeight = FlxG.height;
To get the screen’s dimensions, use width
and height
. These are useful for positioning objects.
screenWidth = FlxG.width;
screenHeight = FlxG.height;
package;
import flixel.FlxG;
import flixel.FlxState;
import flixel.text.FlxText;
class PlayState extends FlxState
{
override function create()
{
super.create();
var text = new FlxText(0, 0, FlxG.width, "The Screen's dimensions\nare " + FlxG.width + "x" + FlxG.height + " pixels", 12);
text.color = 0xff000000;
text.alignment = FlxTextAlign.CENTER;
text.setBorderStyle(FlxTextBorderStyle.SHADOW, 0xFF808080);
text.screenCenter();
add(text);
}
}