2D rigid body (Box2D) in pixel-space coordinates. Owned by a World; create shapes with newRectangleFixture/newCircleFixture. 更多...
#include <Body.h>
Public 成员函数 | |
| Body (World *world, b2Body *body, int id) | |
| Internal: wraps a Box2D body (use World::newBody). | |
| ~Body () | |
| Body (const Body &)=delete | |
| Body & | operator= (const Body &)=delete |
| int | getId () const |
| Stable id used by contact/impact events. | |
| void | setPosition (float x, float y) |
| Position in pixels. | |
| float | getX () const |
| float | getY () const |
| void | setAngle (float radians) |
| Rotation in radians. | |
| float | getAngle () const |
| void | setLinearVelocity (float vx, float vy) |
| Linear velocity in pixels/s. | |
| float | getLinearVelocityX () const |
| float | getLinearVelocityY () const |
| float | getLinearSpeed () const |
| Magnitude of the linear velocity. | |
| float | getMass () const |
| Mass in kilograms (Box2D units). | |
| float | getWorldCenterX () const |
| World center of mass in pixels. | |
| float | getWorldCenterY () const |
| void | setAngularVelocity (float omega) |
| Angular velocity in radians/s. | |
| float | getAngularVelocity () const |
| void | applyForce (float fx, float fy) |
| Force (pixels/s² * kg) applied at the center of mass. | |
| void | applyForceAt (float fx, float fy, float x, float y) |
| Force applied at a world pixel position. | |
| void | applyLinearImpulse (float ix, float iy) |
| Instantaneous linear impulse. | |
| void | applyAngularImpulse (float impulse) |
| Instantaneous angular impulse. | |
| void | setType (const std::string &bodyType) |
| "static" | "kinematic" | "dynamic". | |
| std::string | getType () const |
| void | setFixedRotation (bool fixed) |
| Locks rotation so the body cannot spin. | |
| bool | isFixedRotation () const |
| void | setActive (bool active) |
| Disables/enables the body and its fixtures. | |
| bool | isActive () const |
| void | setBullet (bool bullet) |
| CCD bullet mode (recommended for fast small bodies). | |
| bool | isBullet () const |
| void | setAwake (bool awake) |
| Wakes / sleeps the body manually. | |
| bool | isAwake () const |
| Fixture * | newRectangleFixture (float width, float height, float density=1.f, float friction=0.2f, float restitution=0.f) |
| width/height in pixels; density kg/m² (Box2D units). | |
| Fixture * | newRectangleFixtureAt (float width, float height, float offsetX, float offsetY, float density=1.f, float friction=0.2f, float restitution=0.f) |
| Rectangle fixture with a local pixel-space offset from the body origin. | |
| Fixture * | newCircleFixture (float radius, float density=1.f, float friction=0.2f, float restitution=0.f) |
| void | destroy () |
| Destroys the body inside its world. | |
| World * | getWorld () |
| Owning world / raw Box2D body. | |
| b2Body * | raw () |
| const b2Body * | raw () const |
| void | invalidate () |
| Internal: marks the wrapper invalid after world destruction. | |
友元 | |
| class | World |
| class | Fixture |
详细描述
2D rigid body (Box2D) in pixel-space coordinates. Owned by a World; create shapes with newRectangleFixture/newCircleFixture.
构造及析构函数说明
◆ Body() [1/2]
| eve::physics::Body::Body | ( | World * | world, |
| b2Body * | body, | ||
| int | id | ||
| ) |
Internal: wraps a Box2D body (use World::newBody).
◆ ~Body()
| eve::physics::Body::~Body | ( | ) |
◆ Body() [2/2]
|
delete |
成员函数说明
◆ applyAngularImpulse()
| void eve::physics::Body::applyAngularImpulse | ( | float | impulse | ) |
◆ applyForce()
| void eve::physics::Body::applyForce | ( | float | fx, |
| float | fy | ||
| ) |
Force (pixels/s² * kg) applied at the center of mass.
◆ applyForceAt()
| void eve::physics::Body::applyForceAt | ( | float | fx, |
| float | fy, | ||
| float | x, | ||
| float | y | ||
| ) |
Force applied at a world pixel position.
引用了 eve::physics::World::toMeters(), x , 以及 y.
◆ applyLinearImpulse()
| void eve::physics::Body::applyLinearImpulse | ( | float | ix, |
| float | iy | ||
| ) |
◆ destroy()
| void eve::physics::Body::destroy | ( | ) |
Destroys the body inside its world.
引用了 f, eve::physics::World::forgetBody(), eve::physics::World::forgetFixture(), invalidate() , 以及 eve::physics::World::raw().
◆ getAngle()
◆ getAngularVelocity()
◆ getId()
|
inline |
Stable id used by contact/impact events.
被这些函数引用 eve::physics::Fixture::getBodyId().
◆ getLinearSpeed()
| float eve::physics::Body::getLinearSpeed | ( | ) | const |
◆ getLinearVelocityX()
| float eve::physics::Body::getLinearVelocityX | ( | ) | const |
◆ getLinearVelocityY()
| float eve::physics::Body::getLinearVelocityY | ( | ) | const |
◆ getMass()
| float eve::physics::Body::getMass | ( | ) | const |
◆ getType()
◆ getWorld()
◆ getWorldCenterX()
| float eve::physics::Body::getWorldCenterX | ( | ) | const |
◆ getWorldCenterY()
| float eve::physics::Body::getWorldCenterY | ( | ) | const |
◆ getX()
| float eve::physics::Body::getX | ( | ) | const |
◆ getY()
| float eve::physics::Body::getY | ( | ) | const |
◆ invalidate()
| void eve::physics::Body::invalidate | ( | ) |
◆ isActive()
◆ isAwake()
◆ isBullet()
◆ isFixedRotation()
◆ newCircleFixture()
| Fixture * eve::physics::Body::newCircleFixture | ( | float | radius, |
| float | density = 1.f, |
||
| float | friction = 0.2f, |
||
| float | restitution = 0.f |
||
| ) |
引用了 Fixture, raw() , 以及 eve::physics::World::toMeters().
◆ newRectangleFixture()
| Fixture * eve::physics::Body::newRectangleFixture | ( | float | width, |
| float | height, | ||
| float | density = 1.f, |
||
| float | friction = 0.2f, |
||
| float | restitution = 0.f |
||
| ) |
width/height in pixels; density kg/m² (Box2D units).
引用了 height, newRectangleFixtureAt() , 以及 width.
◆ newRectangleFixtureAt()
| Fixture * eve::physics::Body::newRectangleFixtureAt | ( | float | width, |
| float | height, | ||
| float | offsetX, | ||
| float | offsetY, | ||
| float | density = 1.f, |
||
| float | friction = 0.2f, |
||
| float | restitution = 0.f |
||
| ) |
Rectangle fixture with a local pixel-space offset from the body origin.
引用了 Fixture, height, raw(), eve::physics::World::toMeters() , 以及 width.
被这些函数引用 newRectangleFixture().
◆ operator=()
◆ raw() [1/2]
|
inline |
◆ raw() [2/2]
◆ setActive()
| void eve::physics::Body::setActive | ( | bool | active | ) |
◆ setAngle()
◆ setAngularVelocity()
| void eve::physics::Body::setAngularVelocity | ( | float | omega | ) |
◆ setAwake()
| void eve::physics::Body::setAwake | ( | bool | awake | ) |
◆ setBullet()
| void eve::physics::Body::setBullet | ( | bool | bullet | ) |
◆ setFixedRotation()
| void eve::physics::Body::setFixedRotation | ( | bool | fixed | ) |
◆ setLinearVelocity()
| void eve::physics::Body::setLinearVelocity | ( | float | vx, |
| float | vy | ||
| ) |
◆ setPosition()
| void eve::physics::Body::setPosition | ( | float | x, |
| float | y | ||
| ) |
◆ setType()
| void eve::physics::Body::setType | ( | const std::string & | bodyType | ) |
友元及相关函数文档
◆ Fixture
|
friend |
被这些函数引用 newCircleFixture() , 以及 newRectangleFixtureAt().
◆ World
该类的文档由以下文件生成: