cocos2dx 3.x版本多边形刚体

前端之家收集整理的这篇文章主要介绍了cocos2dx 3.x版本多边形刚体前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
//多边形的点:
Point verts1[] = {
        Point(-146.5f,155.1f),Point(-146.5f,-87.6f),Point(-140.9f,-88.1f),Point(-140.8f,155.5f),Point(162.8f,154.6f),Point(162.9f,-27.7f),Point(12.0f,-29.0f),-33.9f),Point(167.6f,-34.6f),Point(168.7f,154.4f),Point(235.0f,Point(235.3f,-91.6f),Point(238.8f,-93.2f),Point(239.8f,-91.5f),Point(239.1f,159.2f),Point(-238.3f,159.0f),Point(-238.7f,155.0f),Point(-147.4f,154.9f)
    };

auto spEdgePolygon1 = Sprite::create("HelloWorld.png");
spEdgePolygon1->setTag(1);
//创建多边形刚体
auto borderUpper = PhysicsBody::createEdgePolygon(verts1,18);
spEdgePolygon1->setPhysicsBody(borderUpper);
spEdgePolygon1->setPosition(Point(visibleSize.width/2,visibleSize.height/2));
this->addChild(spEdgePolygon1);

猜你在找的Cocos2d-x相关文章