您好,登錄后才能下訂單哦!
#include "HelloWorldScene.h" #include "MyLayer.h" using namespace cocos2d; CCScene* HelloWorld::scene() { CCScene * scene = NULL; do { // 'scene' is an autorelease object scene = CCScene::create(); CC_BREAK_IF(! scene); // 'layer' is an autorelease object HelloWorld *layer = HelloWorld::create(); CC_BREAK_IF(! layer); // add layer as a child to scene scene->addChild(layer); } while (0); // return the scene return scene; } // on "init" you need to initialize your instance bool HelloWorld::init() { bool bRet = false; do { ////////////////////////////////////////////////////////////////////////// // super init first ////////////////////////////////////////////////////////////////////////// CC_BREAK_IF(! CCLayer::init()); //得到屏幕的大小 CCSize isize = CCDirector::sharedDirector()->getVisibleSize(); //建立一個精靈 CCSprite *pSprite = CCSprite::create("grossinis_sister1.png"); //設(shè)置精靈的起始位置 pSprite->setPosition(ccp(50,isize.height / 2)); //在層中添加精靈 this->addChild(pSprite); //定義移動方法 CCMoveTo *moveto = CCMoveTo::create(5,ccp(250,150)); //精靈執(zhí)行移動方法 pSprite->runAction(moveto); // this->addChild(nineGile); bRet = true; } while (0); return bRet; } void HelloWorld::touchDown(CCObject*pObject,CCControlEvent event) { CCLOG("Touch Down"); } void HelloWorld::menuCloseCallback(CCObject* pSender) { // "close" menu item clicked // CCDirector::sharedDirector()->end(); CCDirector::sharedDirector()->replaceScene(CCTransitionSlideInT::create(3.0,CMyLayer::scence())); }
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。