标签:style blog io color os sp on div log
Scene* HelloWorld::createScene() { auto scene = Scene::createWithPhysics(); scene->getPhysicsWorld()->setDebugDrawMask(PhysicsWorld::DEBUGDRAW_ALL); auto layer = HelloWorld::create(); scene->addChild(layer); return scene; } bool HelloWorld::init() { if ( !Layer::init() ) { return false; } Size size = Director::getInstance()->getVisibleSize(); Vec2 origin = Director::getInstance()->getVisibleOrigin(); return true; } void HelloWorld::onEnter() { addEdge(); addBall(); } void HelloWorld::addEdge() { Size size = Director::getInstance()->getVisibleSize(); Size liteSize=size; liteSize.width-=10; liteSize.height-=20; auto edgeBox=PhysicsBody::createEdgeBox(liteSize); auto node=Node::create(); node->setPosition(size.width/2,size.height/2); node->setPhysicsBody(edgeBox); addChild(node); } void HelloWorld::addBall() { Size size = Director::getInstance()->getVisibleSize(); auto ball=Sprite::create("ball.png"); ball->setPosition(size.width/2,size.height/2); ball->setPhysicsBody(PhysicsBody::createBox(ball->getContentSize())); addChild(ball); }
标签:style blog io color os sp on div log
原文地址:http://www.cnblogs.com/yufenghou/p/4154596.html