标签:style blog color os io ar 数据 div cti
// on "init" you need to initialize your instance bool HelloWorld::init() { ////////////////////////////// // 1. super init first if ( !CCLayer::init() ) { return false; } CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize(); CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin(); CCSize winSize = CCDirector::sharedDirector()->getWinSize(); auto *png1=CCSprite::create("1.png"); png1->setPosition(ccp(0,120)); addChild(png1); CCFiniteTimeAction *action = CCSequence::create( CCMoveBy::create(2.0f, CCPointMake(winSize.width / 2, 0)), CCCallFunc::create(this, callfunc_selector(HelloWorld::actionCallback)), NULL); CCFiniteTimeAction *actionN = CCSequence::create( CCMoveBy::create(2.0f, CCPointMake(winSize.width / 2, 0)), CCCallFuncN::create(this, callfuncN_selector(HelloWorld::actionCallbackN)), NULL); CCFiniteTimeAction *actionND = CCSequence::create( CCMoveBy::create(2.0f, CCPointMake(winSize.width / 2, 0)), CCCallFuncND::create(this, callfuncND_selector(HelloWorld::actionCallbackND), (void *) "Callback Data"), NULL); png1->runAction(action); //png1->runAction(actionN); //png1->runAction(actionND); return true; } void HelloWorld::actionCallback() { CCSize winSize = CCDirector::sharedDirector()->getWinSize(); CCLabelTTF *label = CCLabelTTF::create("Action Callback!", "Marker Felt", 32); label->setPosition(ccp(winSize.width / 2, winSize.height / 2)); this->addChild(label); } void HelloWorld::actionCallbackN(CCNode *pSender) { CCSprite *sprite = (CCSprite *) pSender; // 回调变红色 sprite->setColor(ccRED); } void HelloWorld::actionCallbackND(CCNode *pSender, void *data) { CCSize winSize = CCDirector::sharedDirector()->getWinSize(); CCSprite *sprite = (CCSprite *) pSender; // 回调变蓝色 sprite->setColor(ccBLUE); // 接收回调数据 CCLabelTTF *label = CCLabelTTF::create((char *) data, "Marker Felt", 32); label->setPosition(ccp(winSize.width / 2, winSize.height / 2)); this->addChild(label); CCLog((char *) data); }
标签:style blog color os io ar 数据 div cti
原文地址:http://www.cnblogs.com/yufenghou/p/3950399.html