1

I am making pong in cocos2dx and would like to make a function that would take a sprite as an input together with the direction of movement. VC2012 spits out an error on compilation

Error 1 error C2061: syntax error : identifier 'Sprite' (..\Classes\AppDelegate.cpp) Error 2 error C2061: syntax error : identifier 'Sprite' (..\Classes\HelloWorldScene.cpp)
Error 4 error C2660: 'HelloWorld::movePaddle' : function does not take 2 arguments Error 5 error C2511: 'void HelloWorld::movePaddle(cocos2d::Sprite *,int)' : overloaded member function not found in 'HelloWorld'

Here is the function:

void HelloWorld::movePaddle(Sprite *paddle, int direction) {
    paddle->runAction(MoveBy::create(1,Point(0,15*direction)));
}

Here is the function prototype in the .h file:

void HelloWorld::movePaddle(Sprite *paddle, int direction);

What am I doing wrong?

I apologise if this question seems stupid, I'm very new.

2
  • Two possible causes: You have not included the header file that defines cocos2d::Sprite. Or you forgot using namespace cocos2d (which I personally recommend against, I'd rather write codos2d::Sprite). Apr 10, 2014 at 14:40
  • OMG was about to reply that I found it to be the cocos2d::Sprite. How do I mark as solved question? Apr 10, 2014 at 14:44

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.