Esempio n. 1
0
void Physics3DComponent::onEnter()
{
    Component::onEnter();
    
    if (_physics3DObj->getPhysicsWorld() == nullptr && _owner)
    {
        auto scene = _owner->getScene();
        if (scene)
            addToPhysicsWorld(scene->getPhysics3DWorld());
    }
}
Esempio 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();
}
Esempio n. 3
0
void PhysicsBody::onEnter()
{
    addToPhysicsWorld();
}