Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲
 Android教程網 >> Android技術 >> 關於Android編程 >> Cocos2D-x游戲開發之CCMoveTo CCMoveBy and CCscaleTo CCBlink

Cocos2D-x游戲開發之CCMoveTo CCMoveBy and CCscaleTo CCBlink

編輯:關於Android編程

歇了兩三天,,嘿嘿是不是感覺我沒有恆心啊。。。麼事今天咱們繼續。

今天我們學習一下CCMoveTo CCMoveBy CCscaleTo CCBlink 這四個類,比較簡單看看代碼就清楚了。

bool HelloWorld::init()
{
bool bRet = false;
do
{
CC_BREAK_IF(! CCLayer::init());
CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
"CloseNormal.png",
"CloseSelected.png",
this,
menu_selector(HelloWorld::menuCloseCallback));
CC_BREAK_IF(! pCloseItem);


// Place the menu item bottom-right conner.
pCloseItem->setPosition(ccp(CCDirector::sharedDirector()->getWinSize().width - 20, 20));


// Create a menu with the "close" menu item, it's an auto release object.
CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
pMenu->setPosition(CCPointZero);
CC_BREAK_IF(! pMenu);


// Add the menu to HelloWorld layer as a child layer.
this->addChild(pMenu, 1);
CCSprite *sprite = CCSprite::create("sprite.png");
CCSize size = CCDirector::sharedDirector()->getWinSize();
sprite->setPosition(ccp(size.width/2,size.height/2));
this->addChild(sprite);
CCMoveTo *action = CCMoveTo::create(3.0f,ccp(size.width,size.height/2));
sprite->runAction(action);


CCSprite *sprite1 = CCSprite::create("sprite.png");
sprite1->setPosition(ccp(0,0));
this->addChild(sprite1);
CCMoveBy *action1 = CCMoveBy::create(10.0f,ccp(size.width,size.height));
sprite1->runAction(action1);


CCScaleTo *scale = CCScaleTo::create(6.0f,1.0f,5.0f);
sprite1->runAction(scale);
CCBlink *blink = CCBlink::create(6.0f,50);
sprite1->runAction(blink);
bRet = true;
} while (0);


return bRet;
}

  1. 上一頁:
  2. 下一頁:
熱門文章
閱讀排行版
Copyright © Android教程網 All Rights Reserved