本文整理汇总了C++中PhysicsWorld::setDebugDrawMask方法的典型用法代码示例。如果您正苦于以下问题:C++ PhysicsWorld::setDebugDrawMask方法的具体用法?C++ PhysicsWorld::setDebugDrawMask怎么用?C++ PhysicsWorld::setDebugDrawMask使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhysicsWorld
的用法示例。
在下文中一共展示了PhysicsWorld::setDebugDrawMask方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
bool TMenu::init()
{
Layer::init();
Menu * menu = Menu::create();
addChild(menu);
for (int i = 0; i < sizeof(title) / sizeof(*title); ++i)
{
MenuItemFont * item = MenuItemFont::create(title[i], [](Ref * sender){
MenuItem * item = (MenuItem *)sender;
int i = item->getTag() - 1000;
Layer * l = NULL;
if (title[i] == "T01CPP11") l = T01CPP11::create();
else if (title[i] == "T02Vector") l = T02Vector::create();
else if (title[i] == "T03Map") l = T03Map::create();
else if (title[i] == "T04Label") l = T04Label::create();
else if (title[i] == "T05Touch") l = T05Touch::create();
else if (title[i] == "T06Box2D") l = T06Box2D::create();
else if (title[i] == "T07PhysicsWorld") l = T07PhysicsWorld::create();
else if (title[i] == "T08RayCast") l = T08RayCast::create();
else if (title[i] == "T09Joint") l = T09Joint::create();
else if (title[i] == "T10MultiShapes") l = T10MultiShapes::create();
else if (title[i] == "T11FlyppyBird") l = T11FlyppyBird::create();
if (l != NULL)
{
TBack * b = TBack::create();
//Scene * s = Scene::create();
Scene * s = Scene::createWithPhysics(); // 3.x ÎïÀíÊÀ½ç
PhysicsWorld * world = s->getPhysicsWorld();
world->setDebugDrawMask(PhysicsWorld::DEBUGDRAW_ALL);
s->addChild(b);
s->addChild(l);
Director::getInstance()->pushScene(s);
}
});
menu->addChild(item);
item->setTag(1000 + i);
}
menu->alignItemsVertically();
// ´¥Ãþ
auto ev = EventListenerTouchOneByOne::create();
//ev->onTouchBegan = std::bind(&TMenu::touchBegan, this, std::placeholders::_1, std::placeholders::_2);
ev->onTouchBegan = CC_CALLBACK_2(TMenu::touchBegan, this);
ev->onTouchMoved = [&](Touch * touch, Event *){
setPositionY(getPositionY() + touch->getDelta().y);
};
_eventDispatcher->addEventListenerWithSceneGraphPriority(ev, this);
return true;
}
示例2: createScene
Scene* HelloGravity::createScene() {
auto scene = Scene::createWithPhysics();
PhysicsWorld* world = scene->getPhysicsWorld();
world->setGravity(Vec2(0, -500));
world->setSpeed(1.0f);
world->setDebugDrawMask(PhysicsWorld::DEBUGDRAW_ALL);
auto layer = HelloGravity::create();
scene->addChild(layer);
return scene;
}
示例3: createPhysicsScene
// 物理空間を含めたシーンの生成
Scene* SceneCreator::createPhysicsScene( Layer* childLayer, const Vect& gravity, bool isDebug, float speed )
{
Scene* scene { Scene::createWithPhysics() };
PhysicsWorld* world { scene->getPhysicsWorld() };
world->setGravity( gravity );
world->setSpeed( speed );
if ( isDebug )
{
world->setDebugDrawMask( PhysicsWorld::DEBUGDRAW_ALL );
}
scene->addChild( childLayer );
return scene;
}
示例4:
Scene* Practice1::createScene()
{
// 'scene' is an autorelease object
//auto scene = Scene::create();
auto scene = Scene::createWithPhysics();
// 'layer' is an autorelease object
auto layer = Practice1::create();
// add layer as a child to scene
scene->addChild(layer);
PhysicsWorld* world = scene->getPhysicsWorld();
world->setGravity(Vec2(0, -100));
world->setSpeed(1.0f);
world->setDebugDrawMask(PhysicsWorld::DEBUGDRAW_ALL);
// return the scene
return scene;
}
示例5: setupPhysics
void SinglePlayerScene::setupPhysics()
{
Size visibleSize = Director::getInstance()->getVisibleSize();
float visibleHeight = visibleSize.height;
PhysicsWorld* world = this->getScene()->getPhysicsWorld();
world->setGravity(Vec2(0, (visibleHeight / 320.0f) * -98.0f));
world->setSpeed(GAME_SPEED);
world->setDebugDrawMask(DEBUGDRAW_OPTIONS);
Vec2 takyanPos = _takyan->getPosition();
PhysicsBody *takyanBody = PhysicsBody::createCircle(_takyan->getContentSize().width * BALL_RADIUS, PhysicsMaterial(0.01f, 1.0f, 1.0f)); //_takyan->getPhysicsBody();
float takyanMass = takyanBody->getMass();
float velocityLimit = takyanMass * 150.0f;
takyanBody->setMass(takyanMass * 100.0f);
takyanBody->setRotationEnable(false);
takyanBody->setVelocityLimit(velocityLimit);
_takyan->setPhysicsBody(takyanBody);
PHYSICS_MASK(takyanBody, MASK_TAKYAN, MASK_BOUNDS | MASK_KICKER, MASK_BOUNDS | MASK_KICKER);
Size takyanSize = _takyan->getContentSize();
takyanSize.height *= 0.8f;
PhysicsMaterial material(0.0025f, 0.0f, 1.0f);
PhysicsBody *takyanTailBody = PhysicsBody::createCircle(takyanSize.width, material);
takyanTailBody->setMass(takyanMass * 0.01);
takyanTailBody->setRotationEnable(false);
takyanTailBody->setLinearDamping(1.0f);
takyanTailBody->setVelocityLimit(velocityLimit * 0.5f);
_takyanTail->setPhysicsBody(takyanTailBody);
PHYSICS_MASK(takyanTailBody, MASK_TAKYAN_TAIL, 0, MASK_FLOOR);
Vec2 diff = _takyanTail->getPosition() - _takyan->getPosition();
Vec2 anch1 = Vec2::ANCHOR_MIDDLE;
Vec2 anch2 = Vec2::ANCHOR_MIDDLE;
auto jointS = PhysicsJointLimit::construct(takyanBody, takyanTailBody, anch1, anch2, 0, diff.y);
jointS->setCollisionEnable(false);
world->addJoint(jointS);
PhysicsBody *kickerBody = PhysicsBody::createCircle(_kicker->getContentSize().width * KICKER_RADIUS, PhysicsMaterial(1.0f, 1.0f, 1.0f)); //_kicker->getPhysicsBody();
kickerBody->setDynamic(false);
kickerBody->setEnable(false);
_kicker->setPhysicsBody(kickerBody);
PHYSICS_MASK(kickerBody, MASK_KICKER, MASK_TAKYAN, MASK_TAKYAN);
int takyans = MASK_TAKYAN | MASK_TAKYAN_TAIL;
auto floorBody = PhysicsBody::createBox(_floorBounds->getContentSize(), PhysicsMaterial(1.0f, 0.3f, 0.7f)); //_floorBounds->getPhysicsBody();
floorBody->setDynamic(false);
_floorBounds->setPhysicsBody(floorBody);
PHYSICS_MASK(floorBody, MASK_BOUNDS, takyans, takyans);
auto ceilingBody = PhysicsBody::createBox(_ceilingBounds->getContentSize(), PhysicsMaterial(1.0f, 0.3f, 0.7f));
ceilingBody->setDynamic(false);
_ceilingBounds->setPhysicsBody(ceilingBody);
PHYSICS_MASK(ceilingBody, MASK_BOUNDS, MASK_TAKYAN, MASK_TAKYAN);
Size wallSize = _leftWallBounds->getContentSize();
wallSize.height *= 5.0f;
auto leftWallBody = PhysicsBody::createBox(wallSize); //_leftWallBounds->getPhysicsBody();
leftWallBody->setDynamic(false);
_leftWallBounds->setPhysicsBody(leftWallBody);
PHYSICS_MASK(leftWallBody, MASK_WALLS, takyans, MASK_TAKYAN);
auto rightWallBody = PhysicsBody::createBox(wallSize); //_rightWallBounds->getPhysicsBody();
rightWallBody->setDynamic(false);
_rightWallBounds->setPhysicsBody(rightWallBody);
PHYSICS_MASK(rightWallBody, MASK_WALLS, takyans, MASK_TAKYAN);
}