ShareSDK_C2D/Classes/HelloWorldScene.cpp
// on "init" you need to initialize your instance
on "init" you need to initialize your instance
on " init " you need to initialize your instance
bool HelloWorld::init()
{
    if ( !CCLayer::init() )
    {
        return false;
    }
    CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
                                        "CloseNormal.png",
                                        "CloseSelected.png",
                                        this,
                                        menu_selector(HelloWorld::menuCloseCallback) );
    pCloseItem->setPosition( ccp(CCDirector::sharedDirector()->getWinSize().width - 20, 20) );
    CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
    pMenu->setPosition( CCPointZero );
    this->addChild(pMenu, 1);
    CCLabelTTF* pLabel = CCLabelTTF::create("Hello Share SDK", "Arial", 54);
    CCSize size = CCDirector::sharedDirector()->getWinSize();
    pLabel->setPosition( ccp(size.width / 2, size.height - 20) );
    this->addChild(pLabel, 1);
    CCSprite* pSprite = CCSprite::create("HelloWorld.png");
    pSprite->setPosition( ccp(size.width/2, size.height/2) );
    this->addChild(pSprite, 0);
    std::string id = "ic_launcher.png";
    CCMenuItemImage* pSSDKMenu = CCMenuItemImage::create(id.c_str(), id.c_str(), this, menu_selector(HelloWorld::eventMenuCallback));
    pMenu->addChild(pSSDKMenu, 0, 101);
    CCPoint ltPos = ccp((size.width) / 2, (size.height) / 2);
    pSSDKMenu->setPosition(ltPos);
    return true;
}
bool HelloWorld :: init ( ) { if ( ! CCLayer :: init ( ) ) { return false ; } CCMenuItemImage * pCloseItem = CCMenuItemImage :: create ( " " , " " , this , menu_selector ( HelloWorld :: menuCloseCallback ) ) ; pCloseItem -> setPosition ( ccp ( CCDirector :: sharedDirector ( ) -> getWinSize ( ) . width - 20 , 20 ) ) ; CCMenu * pMenu = CCMenu :: create ( pCloseItem , NULL ) ; pMenu -> setPosition ( CCPointZero ) ; this -> addChild ( pMenu , 1 ) ; CCLabelTTF * pLabel = CCLabelTTF :: create ( " " , " " , 54 ) ; CCSize size = CCDirector :: sharedDirector ( ) -> getWinSize ( ) ; pLabel -> setPosition ( ccp ( size . width / 2 , size . height - 20 ) ) ; this -> addChild ( pLabel , 1 ) ; CCSprite * pSprite = CCSprite :: create ( " " ) ; pSprite -> setPosition ( ccp ( size . width / 2 , size . height / 2 ) ) ; this -> addChild ( pSprite , 0 ) ; std :: string id = " " ; CCMenuItemImage * pSSDKMenu = CCMenuItemImage :: create ( id . c_str ( ) , id . c_str ( ) , this , menu_selector ( HelloWorld :: eventMenuCallback ) ) ; pMenu -> addChild ( pSSDKMenu , 0 , 101 ) ; CCPoint ltPos = ccp ( ( size . width ) / 2 , ( size . height ) / 2 ) ; pSSDKMenu -> setPosition ( ltPos ) ; return true ; }
on "init" you need to initialize your instance
on " init " you need to initialize your instance
////////////////////////////// // 1. super init first ///////////////////////////// // 2. add a menu item with "X" image, which is clicked to quit the program //    you may modify it. // add a "close" icon to exit the progress. it's an autorelease object // create menu, it's an autorelease object ///////////////////////////// // 3. add your codes below... // add a label shows "Hello World" // create and initialize a label // ask director the window size // position the label on the center of the screen // add the label as a child to this layer // add "HelloWorld" splash screen" // position the sprite on the center of the screen // add the sprite as a child to this layer