首页 > 其他 > 详细

cocos3 初识物理引擎

时间:2014-12-09 22:50:30      阅读:268      评论:0      收藏:0      [点我收藏+]
Scene* HelloWorld::createScene()
{
    // ‘scene‘ is an autorelease object
    auto scene = Scene::createWithPhysics();
    scene->getPhysicsWorld()->setDebugDrawMask(PhysicsWorld::DEBUGDRAW_ALL);
    // ‘layer‘ is an autorelease object
    auto layer = HelloWorld::create();

    // add layer as a child to scene
    scene->addChild(layer);

    // return the scene
    return scene;
}

 

 

void HelloWorld::onEnter()
{
    Layer::onEnter();
    addEdge();
}

 

 

void HelloWorld::addEdge()
{
    Size visibleSize=Director::getInstance()->getVisibleSize();
    auto body=PhysicsBody::createEdgeBox(visibleSize);

    auto node=Node::create();
    node->setPhysicsBody(body);
    node->setPosition(visibleSize.width/2,visibleSize.height/2);
    addChild(node);

}

 

cocos3 初识物理引擎

原文:http://www.cnblogs.com/yufenghou/p/4154118.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!