Built-in Components
Built-in components are first-class Lua classes and can also be added through
the editor or actor:AddComponent(type_name).
Transform
Properties
actorkeyenabledxyrotation
Transform stores local transform values. World transform is derived by the
engine and is not directly exposed as writable Lua properties.
SpriteRenderer
Properties
actorkeyenabledspritergbapivot_xpivot_yscale_xscale_ysprite_rowsprite_columnsorting_orderauto_sorting_order
Methods
| Method | Description |
|---|---|
SetSpriteCell(row, column) |
Convenience setter for sprite_row / sprite_column |
Notes
spriteis the image resource name, for exampleimages/Run.png- draw order is ascending
sorting_order; withauto_sorting_orderset, sprites of the samesorting_orderalso sort by world y (lower on screen draws in front, top-down y-sorting). Remaining ties keep submission order. - spritesheet slicing comes from project metadata in
.engine/project/spritesheets.json - custom gameplay components can store sub-sprite references as encoded strings,
but
SpriteRendereritself still uses separate row / column fields
Rigidbody
Properties
actorkeyenabledxybody_typeprecisegravity_scaledensityangular_frictionlinear_frictionrotationhas_colliderhas_triggercollider_typewidthheightradiustrigger_typetrigger_widthtrigger_heighttrigger_radiusfrictionbouncinesscollider_pointscollision_layercollision_mask
collider_type 为 box、circle、capsule(竖直,radius 与总高 height,
要求 height >= 2 * radius)或 polygon(collider_points 为 3..8 个局部 x/y 点对,
取凸包)。collision_layer 是 1..31 的层号;collision_mask 是可碰撞层的位掩码
(第 n 层为 1 << (n - 1),默认全部)。两个物体仅在双方掩码都接受对方层时碰撞。
Methods
| Method | Description |
|---|---|
OnStart() |
Internal lifecycle hook |
OnDestroy() |
Internal lifecycle hook |
AddForce(vec) |
Adds force |
ApplyImpulse(vec) |
Applies a linear impulse at the center of mass |
AddTorque(value) |
Adds torque |
GetMass() |
Returns body mass |
SetVelocity(vec) |
Sets linear velocity |
SetPosition(vec) |
Sets position |
SetRotation(degrees) |
Sets rotation |
SetAngularVelocity(value) |
Sets angular velocity |
SetGravityScale(value) |
Sets gravity scale |
SetUpDirection(vec) |
Sets orientation from up vector |
SetRightDirection(vec) |
Sets orientation from right vector |
GetPosition() |
Returns Vector2 |
GetRotation() |
Returns rotation |
GetVelocity() |
Returns Vector2 |
GetAngularVelocity() |
Returns angular velocity |
GetGravityScale() |
Returns gravity scale |
GetUpDirection() |
Returns Vector2 |
GetRightDirection() |
Returns Vector2 |
Notes
pocket2d derives an effective_body_type internally for dynamic actor
hierarchies. The authored Lua-visible body_type remains the requested value.
Motion ownership: a dynamic body owns its pose and writes it to the Transform
after each physics step; kinematic and static bodies follow their Transform
before each step. SetPosition and Physics.MoveCharacter update both, so
either may be used on kinematic bodies. Do not offset a kinematic actor's
Transform for drawing (for example to put a sprite's feet on the ground):
the body follows it. Use the SpriteRenderer pivot instead.
ParticleSystem
Properties
actorkeyenabledxyframes_between_burstsburst_quantityduration_framesstart_scale_minstart_scale_maxstart_speed_minstart_speed_maxrotation_minrotation_maxrotation_speed_minrotation_speed_maxstart_color_rstart_color_gstart_color_bstart_color_aend_color_rend_color_gend_color_bend_color_aemit_radius_minemit_radius_maxemit_angle_minemit_angle_maxgravity_scale_xgravity_scale_ydrag_factorangular_drag_factorend_scaleimagesorting_order
Methods
| Method | Description |
|---|---|
OnStart() |
Internal lifecycle hook |
OnUpdate() |
Internal lifecycle hook |
OnDestroy() |
Internal lifecycle hook |
Stop() |
Stops emission |
Play() |
Starts emission |
Burst() |
Emits one burst immediately |