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

來源:互聯網
上載者:User

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

今天我們學習一下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;
}

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.