您好,登錄后才能下訂單哦!
#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"); //設置精靈的起始位置 pSprite->setPosition(ccp(50,isize.height / 2)); //在層中添加精靈 this->addChild(pSprite); //定義移動方法 CCMoveTo *moveto = CCMoveTo::create(5,ccp(250,150)); //精靈執行移動方法 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())); }
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。