本文整理汇总了C++中PhysicsBody::setCircleFixture方法的典型用法代码示例。如果您正苦于以下问题:C++ PhysicsBody::setCircleFixture方法的具体用法?C++ PhysicsBody::setCircleFixture怎么用?C++ PhysicsBody::setCircleFixture使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhysicsBody
的用法示例。
在下文中一共展示了PhysicsBody::setCircleFixture方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: State
GameState::GameState(StateManager* _stateManager) : State(_stateManager), tileSize(64.0f, 64.0f), playerPosition(0.0f, 4.0f), ballPosition(0.0f, 0.0f), ballVelocity(0.0f, 0.1f),
ballSize(40.0f, 40.0f), playerSize(150, 35.0f), tilesSize(90.0f, 40.0f)
{
tileAmount = 10;
boxWorld = new b2World(yam2d::vec2(0.0f, 0.0f));
boxWorld->SetAllowSleeping(false);
contactListener = new ContactListener();
boxWorld->SetContactListener(contactListener);
map = new yam2d::Map(tileSize.x, tileSize.y);
background = new yam2d::Layer(map, "Background", 1.0f, true, true);
objects = new yam2d::Layer(map, "Objects", 1.0f, true, false);
map->addLayer(yam2d::Map::BACKGROUND0, background);
map->addLayer(yam2d::Map::MAPLAYER0, objects);
backgroundObject = createSpriteGameObject("Textures/menu_background.png", 1280.0f, 720.0f);
playerObject = createSpriteGameObject("Textures/player.png", playerSize.x, playerSize.y);
PhysicsBody* Playerbody = new PhysicsBody(playerObject, boxWorld, 1.0f, 1.0f);
Playerbody->setBoxFixture(playerSize / tileSize, yam2d::vec2(0.0f, 0.0f), playerObject->getRotation(), true);
playerObject->addComponent(Playerbody);
playerObject->setName("Player");
playerObject->getComponent<PhysicsBody>()->getBody()->SetTransform(playerPosition, 0.0f);
ballObject = createSpriteGameObject("Textures/ball.png", ballSize.x, ballSize.y);
PhysicsBody* ballBody = new PhysicsBody(ballObject, boxWorld, 1.0f, 1.0f);
ballBody->setCircleFixture((ballSize.x / tileSize.x) / 2 , true);
ballObject->addComponent(ballBody);
ballObject->setName("Ball");
ballObject->getComponent<PhysicsBody>()->getBody()->SetTransform(ballPosition, 0.0f);
for (int i = 0; i < tileAmount; i++)
{
tileObjects.push_back(createSpriteGameObject("Textures/tile.png", tilesSize.x, tilesSize.y));
objects->addGameObject(tileObjects.back());
PhysicsBody* tileBody = new PhysicsBody(tileObjects.back(), boxWorld, 1.0f, 1.0f);
tileBody->setBoxFixture(tilesSize / tileSize, yam2d::vec2(0.0f, 0.0f), tileObjects.back()->getRotation(), true);
tileObjects.back()->addComponent(tileBody);
tileObjects.back()->setName("Tile");
tileObjects.back()->getComponent<PhysicsBody>()->getBody()->SetTransform(yam2d::vec2(-3.0f + 2 * i, -2.0f), 0.0f);
}
textObject = createTextObject();
textObject->setPosition(8.0f, -5.0f);
background->addGameObject(backgroundObject);
objects->addGameObject(playerObject);
objects->addGameObject(ballObject);
objects->addGameObject(textObject);
}