PhysicsEntity QML Type

An Entity that participates in the Box2D physics world More...

Import Statement: import Bacon2D 1.0





Detailed Description

Property Documentation

active : bool

Returns true if the Body is active, or False if it is sleeping

angularDamping : float

This property is used to reduce the angular velocity. The damping parameter can be larger than 1.0f but the damping effect becomes sensitive to the time step when the damping parameter is large.

angularVelocity : float

This property holds the angular velocity of the entity.

awake : bool

Returns True if the Body is awake, or False if it is sleeping.

body : Body

Box2D Bodyin the physics world

bodyType : enumeration

This property holds the current body type.

PhysicsEntity::BodyType is an enumeration:
Body.Static (default)A static body does not move under simulation and behaves as if it has infinite mass. Internally, Box2D stores zero for the mass and the inverse mass. Static bodies can be moved manually by the user. A static body has zero velocity. Static bodies do not collide with other static or kinematic bodies.
Body.KinematicA kinematic body moves under simulation according to its velocity. Kinematic bodies do not respond to forces. They can be moved manually by the user, but normally a kinematic body is moved by setting its velocity. A kinematic body behaves as if it has infinite mass, however, Box2D stores zero for the mass and the inverse mass. Kinematic bodies do not collide with other kinematic or static bodies.
Body.DynamicA dynamic body is fully simulated. They can be moved manually by the user, but normally they move according to forces. A dynamic body can collide with all body types. A dynamic body always has finite, non-zero mass. If you try to set the mass of a dynamic body to zero, it will automatically acquire a mass of one kilogram and it won’t rotate.

bullet : bool

Game simulation usually generates a sequence of images that are played at some frame rate. This is called discrete simulation. In discrete simulation, rigid bodies can move by a large amount in one time step. If a physics engine doesn't account for the large motion, you may see some objects incorrectly pass through each other. This effect is called tunneling.

By default, Box2D uses continuous collision detection (CCD) to prevent dynamic bodies from tunneling through static bodies. This is done by sweeping shapes from their old position to their new positions. The engine looks for new collisions during the sweep and computes the time of impact (TOI) for these collisions. Bodies are moved to their first TOI and then the solver performs a sub-step to complete the full time step. There may be additional TOI events within a sub-step.

Normally CCD is not used between dynamic bodies. This is done to keep performance reasonable. In some game scenarios you need dynamic bodies to use CCD. For example, you may want to shoot a high speed bullet at a stack of dynamic bricks. Without CCD, the bullet might tunnel through the bricks. Fast moving objects in Box2D can be labeled as bullets. Bullets will perform CCD with both static and dynamic bodies. You should decide what bodies should be bullets based on your game design.

fixedRotation : bool

property alias fixedRotation: itemBody.fixedRotation

You may want a rigid body, such as a character, to have a fixed rotation. Such a body should not rotate, even under load. You can use the fixedRotation property to achieve this.

fixtures : list<Fixture>

This property holds a list of Box2D fixtures contained within the current Body.

gravityScale : float

This property represents the scale to adjust the gravity on a single entity.

linearDamping : float

This property is used to reduce the linear velocity. The damping parameter can be larger than 1.0f but the damping effect becomes sensitive to the time step when the damping parameter is large.

linearVelocity : QPointF

This property holds the linear velocity of the entity's origin in world co-ordinates.

sleepingAllowed : bool

What does sleep mean? Well it is expensive to simulate bodies, so the less we have to simulate the better. When a body comes to rest we would like to stop simulating it.

When Box2D determines that a body (or group of bodies) has come to rest, the body enters a sleep state which has very little CPU overhead. If a body is awake and collides with a sleeping body, then the sleeping body wakes up. Bodies will also wake up if a joint or contact attached to them is destroyed. You can also wake a body manually.

The sleepingAllowed property lets you specify whether a body can sleep and whether a body is created sleeping.

world : World

The world defines the physics world of the game, and all bodies found in the world can interact/react with other bodies in the world.

Signal Documentation


Emitted when the Box2D body has finished initialization

Method Documentation

applyAngularImpulse( impulse)

applyForce( force, point)

applyForceToCenter( force)

applyLinearImpulse( impulse, point)

applyTorque( torque)


getLinearVelocityFromLocalPoint( point)

getLinearVelocityFromWorldPoint( point)





toLocalPoint( worldPoint)

toLocalVector( worldVector)

toWorldPoint( localPoint)

toWorldVector( localVector)