Search code examples
objective-ccocos2d-iphonecocos2d-x

CCEaseInOut animation in cocos2d-X


I am porting a game from cocos2d to cocos2d-X. I am trying to port the following code

id scaleXAction =  [CCEaseInOut actionWithAction:[CCScaleTo actionWithDuration:kDuration1 scaleX:1.0 scaleY:1.0] rate:kRate];
id scaleYAction = [CCEaseInOut actionWithAction:[CCScaleTo actionWithDuration:kDuration2 scaleX:1.0 scaleY:kScaleY2] rate:kRate];

In cocos2d-X the CCEaseInOut code only takes a float entry in the create function? Can anyone please help me convert the code ?

Kind Regards


Solution

  • In cocos2dX you can try this code:

    CCSize screenSize   = CCDirector::sharedDirector()->getVisibleSize();
    
    float   x = screenSize.width;
    float   y = screenSize.height;
    
    CCActionInterval* action =  CCEaseInOut::create(CCScaleTo::create(2.1f,x*2,y*3),1.2f);
    sprite->runAction(action);