View source

class flaxen.component.Position

Available on all platforms

Represents the 2D position of the entity.

Most entities that have renderable components (Image, for example) require a Position before they will display.

  • TODO: The convenience methods all rely on the stage height/width, but what if the stage resizes? Consider adding an asPercentage parameter, as it exists in Offset. Then either require the RenderingSystem to calculate the actual position at render time, or add a method that does the math in here. That has some disadvantages.

Class Fields

static function bottom():Position

static function bottomLeft():Position

static function bottomRight():Position

static function center():Position

static function left():Position

static function match(o1:Position, o2:Position):Bool

static function right():Position

static function safeClone(o:Position):Position

static function top():Position

static function topLeft():Position

static function topRight():Position

static function zero():Position

// Some convenience methods

Instance Fields

var x:Float

var y:Float

function new(x:Float, y:Float):Void

function add(x:Float, y:Float):Position

function clone():Position

function copy(pos:Position):Position

function getAngleTo(pos:Position):Float

Returns an angle between this point and another point, degrees, 0 north

function getDistanceTo(pos:Position):Float

function isInside(rect:Rectangle):Bool

function matches(o:Position):Bool

function set(x:Float, y:Float):Void

function subtract(x:Float, y:Float):Position

function toString():String