VisualNapePhysics
Entity → ceramic.VisualNapePhysics (Class)
Component that links a Ceramic Visual to a Nape physics body.
This class manages the relationship between the visual representation and the physics simulation. The physics body drives the visual's position and rotation after each physics update.
// Create a dynamic physics box
var visual = new Quad();
visual.size(100, 100);
visual.anchor(0.5, 0.5);
visual.pos(400, 300);
visual.nape = new VisualNapePhysics(
DYNAMIC, // Body type
null, // Default box shape
null, // No additional shapes
null, // Default material
visual.x, // X position
visual.y, // Y position
visual.width, // Width
visual.height, // Height
visual.rotation // Rotation
);
// Add to physics space
visual.nape.body.space = app.nape.space;
Instance Members
The visual that this physics component is attached to.
Set automatically when assigned to a visual's nape
property.
The Nape physics body that controls the visual's transform. Can be added to a Space to enable physics simulation.
Destroys the physics component and removes the body from simulation.
- Removes body from its physics space
- Clears the visual's nape reference
- Unregisters from the physics system
nape
new(bodyType: Anonymous, ?shape: nape.shape.Shape, ?shapes: Array<nape.shape.Shape>, ?material: nape.phys.Material, x: Float, y: Float, width: Float, height: Float, rotation: Float): Void
Creates a new physics body linked to a visual.
If no shape is provided, creates a box shape matching the dimensions. The body is not automatically added to any physics space.
Name | Type | Default | Description |
---|---|---|---|
bodyType |
Anonymous | Type of physics body (STATIC, KINEMATIC, or DYNAMIC) | |
shape |
nape.shape.Shape | (optional) | Optional single shape for the body |
shapes |
Array<nape.shape.Shape> | (optional) | Optional array of shapes for compound bodies |
material |
nape.phys.Material | (optional) | Physics material defining friction, elasticity, etc. |
x |
Float | Initial X position (center) | |
y |
Float | Initial Y position (center) | |
width |
Float | Width for default box shape | |
height |
Float | Height for default box shape | |
rotation |
Float | Initial rotation in degrees |
Metadata
Name | Parameters |
---|---|
:build |
ceramic.macros.EntityMacro.buildForCompletion() |
:autoBuild |
ceramic.macros.EntityMacro.buildForCompletion() |
:build |
tracker.macros.EventsMacro.build() |
:autoBuild |
tracker.macros.EventsMacro.build() |