Class l2df.class.component.transform

Last updated 2021-05-28 15:24:22

Transform component.

It controls and handles entity's position, rotation and scale and also processes its modifications.

Inherited from l2df.class.Component class.

Info:

Functions

Transform:added(obj[, kwargs]) Component was added to Entity event.
Transform:removed(obj) Component was removed from Entity event.
Transform:update(obj) Component update event handler.
Transform:liftdown(obj) Component liftdown event handler.
Transform:liftup(obj) Component liftup event handler.

Fields

Transform.data.globalX Entity's global X position in space of the screen (includes parent's transformation).
Transform.data.globalY Entity's global Y position in space of the screen (includes parent's transformation).
Transform.data.globalZ Entity's global Z position in space of the screen (includes parent's transformation).
Transform.data.globalR Entity's global rotation in radians (includes parent's transformation).
Transform.data.globalScalex Entity's global X scale in space of the screen (includes parent's transformation).
Transform.data.globalScaley Entity's global Y scale in space of the screen (includes parent's transformation).
Transform.data.globalScalez Entity's global Z scale in space of the screen (includes parent's transformation).
Transform.data.x Entity's X position in space of the parent entity.
Transform.data.y Entity's Y position in space of the parent entity.
Transform.data.z Entity's Z position in space of the parent entity.
Transform.data.r Entity's rotation in radians in space of the parent entity.
Transform.data.scalex Entity's X scale in space of the parent entity.
Transform.data.scaley Entity's Y scale in space of the parent entity.
Transform.data.scalez Entity's Z scale in space of the parent entity.
Transform.data.centerx Entity's origin X position in space of the parent entity.
Transform.data.centery Entity's origin Y position in space of the parent entity.
Transform.data.facing Entity's X orientation (not a whole axis).


Functions

Methods
Transform:added(obj[, kwargs])
Component was added to Entity event. Adds "transform" key to the Entity.C table.

Parameters:

  • obj l2df.class.entity Entity's instance.
  • kwargs table Keyword arguments.
    • sprites {l2df.class.component.render.Sprite,...} Array of sprites to be added with Render:addSprite() method. (optional)
    • x number Entity's X position. (default 0)
    • y number Entity's Y position. (default 0)
    • z number Entity's Z position. (default 0)
    • r number Entity's rotation in radians. Performed around Z axis in space of the display. (default 0)
    • facing number Entity's X orientation (not a whole axis). Can be 1 or -1 (mirrored). (default 1)
    • scalex number Entity's X scale. (default 1)
    • scaley number Entity's Y scale. (default 1)
    • scalez number Entity's Z scale. (default 1)
    • centerx number Entity's origin X position. (default 0)
    • centery number Entity's origin Y position. (default 0)
Transform:removed(obj)
Component was removed from Entity event. Removes "transform" key from Entity.C table.

Parameters:

Transform:update(obj)
Component update event handler. Calculates "globals": position, rotation, scale (see Fields).

Parameters:

Transform:liftdown(obj)
Component liftdown event handler. Used to generate Transformation object for the current state of the entity and apply it to parent's transformation. It's an important step before calculating "globals": position, rotation and scale (see Fields).

Parameters:

Transform:liftup(obj)
Component liftup event handler. Frees memory allocated by Transform:liftdown().

Parameters:

Fields

Transform.data.globalX number
Entity's global X position in space of the screen (includes parent's transformation). To access use Transform:data() function or Entity.data directly.
Transform.data.globalY number
Entity's global Y position in space of the screen (includes parent's transformation). To access use Transform:data() function or Entity.data directly.
Transform.data.globalZ number
Entity's global Z position in space of the screen (includes parent's transformation). To access use Transform:data() function or Entity.data directly.
Transform.data.globalR number
Entity's global rotation in radians (includes parent's transformation). Performed around Z axis in space of the display. To access use Transform:data() function or Entity.data directly.
Transform.data.globalScalex number
Entity's global X scale in space of the screen (includes parent's transformation). To access use Transform:data() function or Entity.data directly.
Transform.data.globalScaley number
Entity's global Y scale in space of the screen (includes parent's transformation). To access use Transform:data() function or Entity.data directly.
Transform.data.globalScalez number
Entity's global Z scale in space of the screen (includes parent's transformation). To access use Transform:data() function or Entity.data directly.
Transform.data.x number
Entity's X position in space of the parent entity. To access use Transform:data() function or Entity.data directly.
Transform.data.y number
Entity's Y position in space of the parent entity. To access use Transform:data() function or Entity.data directly.
Transform.data.z number
Entity's Z position in space of the parent entity. To access use Transform:data() function or Entity.data directly.
Transform.data.r number
Entity's rotation in radians in space of the parent entity. Performed around Z axis in space of the display. To access use Transform:data() function or Entity.data directly.
Transform.data.scalex number
Entity's X scale in space of the parent entity. To access use Transform:data() function or Entity.data directly.
Transform.data.scaley number
Entity's Y scale in space of the parent entity. To access use Transform:data() function or Entity.data directly.
Transform.data.scalez number
Entity's Z scale in space of the parent entity. To access use Transform:data() function or Entity.data directly.
Transform.data.centerx number
Entity's origin X position in space of the parent entity. To access use Transform:data() function or Entity.data directly.
Transform.data.centery number
Entity's origin Y position in space of the parent entity. To access use Transform:data() function or Entity.data directly.
Transform.data.facing number
Entity's X orientation (not a whole axis). Can be 1 or -1 (mirrored). To access use Transform:data() function or Entity.data directly.