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