コード例 #1
0
void PhysicsWorld::updateBodies()
{
    if (_info->getSpace()->locked_private)
    {
        return;
    }
    
    for (auto body : *_delayAddBodies)
    {
        doAddBody(dynamic_cast<PhysicsBody*>(body));
    }
    
    for (auto body : *_delayRemoveBodies)
    {
        doRemoveBody(dynamic_cast<PhysicsBody*>(body));
    }
    
    _delayAddBodies->removeAllObjects();
    _delayRemoveBodies->removeAllObjects();
}
コード例 #2
0
ファイル: CCPhysicsWorld.cpp プロジェクト: 6520874/pipiGame
void PhysicsWorld::updateBodies()
{
    if (_info->isLocked())
    {
        return;
    }
    
    for (auto& body : _delayAddBodies)
    {
        doAddBody(body);
    }
    
    for (auto& body : _delayRemoveBodies)
    {
        doRemoveBody(body);
    }
    
    _delayAddBodies.clear();
    _delayRemoveBodies.clear();
}
コード例 #3
0
void PhysicsWorld::addBodyOrDelay(PhysicsBody* body)
{
    if (_delayRemoveBodies->getIndexOfObject(body) != CC_INVALID_INDEX)
    {
        _delayRemoveBodies->removeObject(body);
        return;
    }
    
    if (_info->getSpace()->locked_private)
    {
        if (_delayAddBodies->getIndexOfObject(body) == CC_INVALID_INDEX)
        {
            _delayAddBodies->addObject(body);
            _delayDirty = true;
        }
    }else
    {
        doAddBody(body);
    }
}
コード例 #4
0
void PhysicsWorld::updateBodies()
{
    if (m_pInfo->getSpace()->locked)
    {
        return;
    }
    
    for (auto body : *m_pDelayAddBodies)
    {
        doAddBody(dynamic_cast<PhysicsBody*>(body));
    }
    
    for (auto body : *m_pDelayRemoveBodies)
    {
        doRemoveBody(dynamic_cast<PhysicsBody*>(body));
    }
    
    m_pDelayAddBodies->removeAllObjects();
    m_pDelayRemoveBodies->removeAllObjects();
}
コード例 #5
0
ファイル: CCPhysicsWorld.cpp プロジェクト: 6520874/pipiGame
void PhysicsWorld::addBodyOrDelay(PhysicsBody* body)
{
    auto removeBodyIter = _delayRemoveBodies.find(body);
    if (removeBodyIter != _delayRemoveBodies.end())
    {
        _delayRemoveBodies.erase(removeBodyIter);
        return;
    }
    
    if (_info->isLocked())
    {
        if (_delayAddBodies.find(body) == _delayAddBodies.end())
        {
            _delayAddBodies.pushBack(body);
            _delayDirty = true;
        }
    }
    else
    {
        doAddBody(body);
    }
}
コード例 #6
0
void PhysicsWorld::updateBodies()
{
    if (cpSpaceIsLocked(_cpSpace))
    {
        return;
    }
    
    // issue #4944, contact callback will be invoked when add/remove body, _delayAddBodies maybe changed, so we need make a copy.
    auto addCopy = _delayAddBodies;
    _delayAddBodies.clear();
    for (auto& body : addCopy)
    {
        doAddBody(body);
    }
    
    auto removeCopy = _delayRemoveBodies;
    _delayRemoveBodies.clear();
    for (auto& body : removeCopy)
    {
        doRemoveBody(body);
    }
}
コード例 #7
0
void PropertyBoxObject::build()
{

	box = sfg::Box::Create(sfg::Box::VERTICAL);
	box->SetSpacing(3.0f);

	sfg::Button::Ptr _export = sfg::Button::Create("Export");
	_export->GetSignal(sfg::Button::OnLeftClick).Connect(&LevelObject::exportObject, object);
	box->Pack(_export,false);


	sfg::Box::Ptr boxGeneral = sfg::Box::Create(sfg::Box::VERTICAL);
	{

		sfg::Box::Ptr nameBox = sfg::Box::Create();
		{
			nameBox->Pack(sfg::Label::Create("Name:"));

			name = sfg::Entry::Create();
			name->GetSignal(sfg::Entry::OnKeyPress).Connect(&PropertyBoxObject::setObjectName, this);
			nameBox->Pack(name);

		}
		boxGeneral->Pack(nameBox);

		sfg::Box::Ptr positionBox = sfg::Box::Create();
		{
			positionBox->Pack(sfg::Label::Create("Position: "));


			std::stringstream ss;
			ss << object->getPosition().x;
			positionX = sfg::Entry::Create(ss.str());
			positionX->SetRequisition(sf::Vector2f(20.0f, 0.0f));
			positionX->GetSignal(sfg::Widget::OnKeyPress).Connect(&PropertyBoxObject::setObjectPosition, this);
			positionBox->Pack(positionX);


			ss.str("");
			ss << object->getPosition().y;
			positionY = sfg::Entry::Create(ss.str());
			positionY->SetRequisition(sf::Vector2f(20.0f, 0.0f));
			positionY->GetSignal(sfg::Widget::OnKeyPress).Connect(&PropertyBoxObject::setObjectPosition, this);
			positionBox->Pack(positionY);
		}
		boxGeneral->Pack(positionBox, false);

		sfg::Box::Ptr centerBox = sfg::Box::Create();
		{
			centerBox->Pack(sfg::Label::Create("Center: "));


			std::stringstream ss;
			ss << object->getCenter().x;
			centerX = sfg::Entry::Create(ss.str());
			centerX->SetRequisition(sf::Vector2f(20.0f, 0.0f));
			centerX->GetSignal(sfg::Widget::OnKeyPress).Connect(&PropertyBoxObject::setObjectCenter, this);
			centerBox->Pack(centerX);


			ss.str("");
			ss << object->getCenter().y;
			centerY = sfg::Entry::Create(ss.str());
			centerY->SetRequisition(sf::Vector2f(20.0f, 0.0f));
			centerY->GetSignal(sfg::Widget::OnKeyPress).Connect(&PropertyBoxObject::setObjectCenter, this);
			centerBox->Pack(centerY);
		}
		boxGeneral->Pack(centerBox, false);

		sfg::Box::Ptr orientationBox = sfg::Box::Create();
		{
			orientationBox->Pack(sfg::Label::Create("Orientation:"));
			orientation = sfg::ComboBox::Create();
			orientation->AppendItem("Left");
			orientation->AppendItem("Right");
			orientation->GetSignal(sfg::ComboBox::OnSelect).Connect(&PropertyBoxObject::setObjectOrientation, this);

			orientationBox->Pack(orientation);


		}
		boxGeneral->Pack(orientationBox, false);

	}
	box->Pack(boxGeneral);


	box->Pack(sfg::Label::Create("AI"));
	box->Pack(sfg::Separator::Create());

	
	deleteAi = sfg::Button::Create("delete");
	deleteAi->GetSignal(sfg::Button::OnLeftClick).Connect(&PropertyBoxObject::doDeleteAi, this);
	deleteAi->Show(false);

	ais = sfg::ComboBox::Create();

	ais->AppendItem("Plattform");
	ais->AppendItem("Swing");
	ais->AppendItem("Bubble");
	ais->AppendItem("Jumper");
	ais->AppendItem("Player");
	ais->AppendItem("Enemy");
	ais->AppendItem("Event");
	ais->AppendItem("Shroom");
	ais->AppendItem("Particle");
	ais->AppendItem("Bomb");
	ais->AppendItem("");

	aBox = sfg::Box::Create(sfg::Box::VERTICAL);

	aBox->Pack(deleteAi);

	ais->GetSignal(sfg::ComboBox::OnSelect).Connect(&PropertyBoxObject::addAi, this);
	aBox->Pack(ais);


	if (object->getAiComponent())
	{
		addAi(object->getAiComponent()->getType());
	}

	box->Pack(aBox);


	box->Pack(sfg::Label::Create("RENDERER"));
	box->Pack(sfg::Separator::Create());


	deleteRenderer = sfg::Button::Create("delete");
	deleteRenderer->GetSignal(sfg::Button::OnLeftClick).Connect(&PropertyBoxObject::doDeleteRenderer, this);
	deleteRenderer->Show(false);

	renderers = sfg::ComboBox::Create();

	renderers->AppendItem("Renderer");
	renderers->AppendItem("Animation");
	renderers->AppendItem("");


	rBox = sfg::Box::Create(sfg::Box::VERTICAL);

	rBox->Pack(deleteRenderer);

	renderers->GetSignal(sfg::ComboBox::OnSelect).Connect(&PropertyBoxObject::addRenderer, this);

	rBox->Pack(renderers);

	if (object->getRendererComponent())
	{
		addRenderer(object->getRendererComponent()->getType());
	}


	box->Pack(rBox);


	box->Pack(sfg::Label::Create("BODY"));
	box->Pack(sfg::Separator::Create());

	bBox = sfg::Box::Create(sfg::Box::VERTICAL);

	deleteBody = sfg::Button::Create("delete");
	deleteBody->GetSignal(sfg::Button::OnLeftClick).Connect(&PropertyBoxObject::doDeleteBody, this);
	deleteBody->Show(false);

	bBox->Pack(deleteBody);

	addBody = sfg::Button::Create("Add Body");
	addBody->GetSignal(sfg::Button::OnLeftClick).Connect(&PropertyBoxObject::doAddBody, this);
	bBox->Pack(addBody);

	if (object->hasBody)
	{
		doAddBody();

	}
	else
	{
		addBody->Show(true);
	}


	box->Pack(bBox);

}