Cocos2D-x game development-CCMoveBy CCJumpBy CCRotateBy CCAction CCRepeatForever

Source: Internet
Author: User

Now let's learn the basic usage of Cocos2D-x.

CCMoveBy CCJumpBy CCRotateBy CCAction CCRepeatForever


The direct code is as follows:

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 );


PCloseItem-> setPosition (ccp (CCDirector: shareddire()-> getWinSize (). width-20, 20 ));
CCMenu * pMenu = CCMenu: create (pCloseItem, NULL );
PMenu-> setPosition (CCPointZero );
CC_BREAK_IF (! PMenu );
This-> addChild (pMenu, 1 );
// Get window size and place the label upper.
CCSize size = CCDirector: shareddire()-> getWinSize ();
CCSprite * pSprite = CCSprite: create ("sprite.png ");
CC_BREAK_IF (! PSprite );
PSprite-> setPosition (ccp (0, size. height/2 ));
This-> addChild (pSprite, 0 );
CCMoveBy * move = CCMoveBy: create (10.0f, ccp (50, 50 ));
CCJumpBy * jump = CCJumpBy: create (3.0f, ccp (50,1), 100,1 );
CCRotateBy * rote = CCRotateBy: create (1.0f, 100,100 );
CCAction * avt = CCSpawn: create (move, jump, rote, NULL );
CCRepeatForever * action = CCRepeatForever: create (rote );
PSprite-> runAction (action );
PSprite-> runAction (avt );
BRet = true;
} While (0 );


Return bRet;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.