Skip to content
Tesserex edited this page Jan 25, 2012 · 2 revisions

The position component describes an entity's location on the screen. More accurately, its location within a room. The tags for position have two purposes: initialization and within functions / effects.

##Initialization

There is currently only one attribute that the Position tag can take. It can only be used at the highest level inside a State, because it's read on initialization.

<Position persistoffscreen="True" />

The persistoffscreen attribute tells the entity to not be deleted when it goes off the screen (the camera's actual view. All entities are still destroyed when scrolling to another room.) It's a boolean, so it's value can only be "True" or "False", case insensitive.

Remember that this whole tag is optional for initialization, because the Position component will still be created if needed without being explicitly declared.

##X and Y Tags

Inside the position tag, there are two matching tags that you can use to set or alter the entity's position. They can be used at the highest level of a state, in which case they will be evaluated when the state begins, or they can be used inside a function or effect.

<Position>
    <X base="Inherit" offset="8" direction="Inherit" />
    <Y base="Inherit" offset="4" direction="Up" />
</Position>

The X and Y tags are short tags, meaning they have no contents, just attributes. There are three attributes they accept.

Name Required? Type Description
base No Decimal or "Inherit" See below.
offset No Decimal Distance away from the base position.
direction If "offset" is used "Inherit", "Up", "Down", "Left", "Right" Direction of offset.

The base tag allows you to either set a pixel position on the screen, or to inherit a position. Inherit means that this entity will get the exact same position as its parent at the moment it is spawned. This is useful when Mega Man and enemies spawn projectiles in front of them. The reason base is optional is because these tags can also specify a change in position, useful in functions and trigger effects.

Offset is only useful if you used "Inherit" for the base. It would work otherwise, but why bother? Anyway, it specifies a number of pixels away from the inherited position.

Direction specifies the direction of the offset. Like the base, you can say "Inherit" to offset in the direction that the parent entity is facing. This can make sure that weapons always fire forward, not just always to the right. You can also use a direction. Keep in mind that the X tag can only accept "Left" and "Right", while the Y tag can only accept "Up" and "Down".