臨時文件

bool HelloWorld::init()
{
     CCSize     size = CCDirector::sharedDirector()->getWinSize();

     // 建立一個無形節點
     CCNode*     pNode = CCNode::create();
     this->addChild(pNode, 0);

     // 添加菜單項、菜單
     CCMenuItemImage*     pCloseItem = CCMenuItemImage::create("CloseNormal.png", "CloseSelected.png", this,
                                                                           menu_selector(HelloWorld::menuCloseCallback));
     pCloseItem->setPosition(ccp(size.width - 20, 20));
    
     CCMenu*     pMenu = CCMenu::create(pCloseItem, NULL);
     pMenu->setPosition(CCPointZero);
     pNode->addChild(pMenu, 1);

     // 添加顯示文本
     CCLabelTTF*     pLabel     = CCLabelTTF::create("Hello World", "Thonburi", 34);
     pLabel->setPosition(ccp(size.width / 2, size.height - 20));
     pNode->addChild(pLabel, 1);

     // 添加精靈
     CCSprite*     pSprite     = CCSprite::create("HelloWorld.png");
     pSprite->setPosition(ccp(size.width / 2, size.height / 2));
     pNode->addChild(pSprite, 0);
    
     pNode->setScale(0.5f);                                             // 總體縮放
     pNode->setPosition(size.width / 2, size.height / 2);     // 總體移動
     pNode->setRotation(90.0);                                        // 總體旋轉

     return true;
}
相關文章
相關標籤/搜索