Exemplo n.º 1
0
void Physics3DComponent::onEnter()
{
    Component::onEnter();
    
    if (_physics3DObj->getPhysicsWorld() == nullptr && _owner)
    {
        auto scene = _owner->getScene();
        if (scene)
            addToPhysicsWorld(scene->getPhysics3DWorld());
    }
}
Exemplo n.º 2
0
void PhysicsBody::onAdd()
{
    _owner->_physicsBody = this;
    auto contentSize = _owner->getContentSize();
    _ownerCenterOffset.x = 0.5f * contentSize.width;
    _ownerCenterOffset.y = 0.5f * contentSize.height;

    setRotationOffset(_owner->getRotation());

    // component may be added after onEnter() has been invoked, so we should add
    // this line to make sure physics body is added to physics world
    addToPhysicsWorld();
}
Exemplo n.º 3
0
void PhysicsBody::onEnter()
{
    addToPhysicsWorld();
}