Search code examples
visual-studio-2012cocos2d-x

Porting old Code to Cocos2d-x rc0 2.1.3 giving error


I have an old code. I am porting it to new Cocos2d-x rc0 2.1.3 .It is giving me errors in following lines:

1. in GameScene.cpp

CCScene *scene = CCScene::node();
GameScene *layer = GameScene::node();

2. in GameScene.cpp

userPaddle_->runAction(CCMoveTo::actionWithDuration(0.3 * diffX / gameArea_.size.width, destPosition));

3. in GameScene.cpp

CCPoint location = touch->locationInView(touch->view());

4. in GameScene.cpp

if (CCRect::CCRectContainsPoint(touchArea_, location))

5. in GameScene.cpp

if (CCRect::CCRectIntersectsRect(ballRect, CC_SPRITE_RECT(paddle)))

6. in Appdelegate.cpp

pDirector->setOpenGLView(&CCEGLView::sharedOpenGLView());

7. in GameScene.h

// implement the "static node()" method manually
LAYER_NODE_FUNC(HelloWorld);

Solution

  • For the full list of cocos2d-x API changes, please refer to

    http://www.cocos2d-x.org/projects/cocos2d-x/wiki/API_Change_List_from_v1x_to_2x

    and

    http://www.cocos2d-x.org/projects/cocos2d-x/wiki/About_Static_Constructor_API_changes_in_cocos2d-x_v20

    node() -> create()

    actionWithDuation(a,b) -> create(a,b)

    CCRect::CCRectContainsPoint(touchArea_, location) -> touchArea_.containsPoint(location)

    touch->locationInView(touch->view()) -> touch->getLocation()

    CCRect::CCRectIntersectsRect(ballRect, CC_SPRITE_RECT(paddle)) - > ballRect.intersectsRect(CC_SPRITE_RECT(paddle))

    LAYER_NODE_FUNC -> CREATE_FUNC if still exist.

    I forgot the OpenGLView one, but there is one.