#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进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。