#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())); }
本文出自 “风清扬song” 博客,请务必保留此出处http://2309998.blog.51cto.com/2299998/1421042
原文:http://2309998.blog.51cto.com/2299998/1421042