编写日期:2013年02月02日15:53:43
示例一:让一精灵来回移动
关键字:CCMoveBy、CCRepeatForever、reverse()
CCMenuItemImage* playItem = CCMenuItemImage::create(
"CloseNormal.png",
"CloseSelected.png",
this,
menu_selector(GameWorld::menuCloseCallback) );
playItem->setPosition(0, 0);
playItemMenu = CCMenu::create(playItem, NULL);
playItemMenu->setPosition( 0,screensize.height*0.5);
this->addChild(playItemMenu, 1);
moveAction=CCMoveBy::create(1 ,ccp(screensize.width,0));
CCActionInterval *action=(CCActionInterval*)CCSequence::create(moveAction,moveAction->reverse(), NULL);
CCRepeatForever *move = CCRepeatForever::create(action);
playItemMenu->runAction(move);