Cocos2D-X Platformer tutorial Part 1 – Start

All new and shiny cocos2d-x v3 lets start using it. I’ll do this project on windows platform because I don’t have an android phone nor do I have a mac. Aside from that windows’ c++(Visual Studio) seems to be most unforgiving, because some warnings in android/mac were errors here, so what works will surely work on others.

End Result will look like this:

  • Our first task is to load a TmxTilemap into our GameScene
  • AppDelegate class will remain almost unchanged aside from loading our GameScene instead of HelloWorldScene
  • Put these files into the Resources folder
  • Note that as we go on you will not have to replace any code, we will just make additions (unless it is something I completely missed)

  • siddharthshekar


  • j


    • metin

      hmm, I’ll check it later, would you mind telling what the error says, by the way I’m usin cocos2d-x 3.2.0 stable

      • j

        I’m using 3.3beta0 but i’m not sure if that’s much different. There are many compile errors. I’m not sure if it’s that you did not provide main.cpp or .h and appdelegate.h. I am using visual studio and making a win32 project

        • metin

          I did not include those files because I never change them when I create a new project, so yours is probably the same.
          I want you to check a few things.
          1. Did you include the map and sprite files in your resources folder.
          2. How did you import/include/add the class files to Visual studio.
          3. Are the class files (h and cpp) under Classes folder(which is under your project folder)

          • j

            they are in the classes folder which is where i created them. i did include the map and sprite files in the resources folder as well

          • j

            6 warnings. 5 of them say warning C4996 ‘cocos2d::SOMETHING’: was declared depreciated
            the other one says warning LNK4075: ignoring ‘/EDITANDCONTINUE’ due to ‘/SAFESEH’ specification C:Afromanproj.win32AppDelegate.obj Afroman

            2 errors.

            Error 7 error LNK2001: unresolved external symbol “public: virtual void __thiscall AppDelegate::initGLContextAttrs(void)” (?initGLContextAttrs@AppDelegate@@UAEXXZ)

            Thanks for responding btw

  • metin

    well then you will have to tell me about the compile error otherwise I can’t help you.
    and about my second question, how did you add the classes to visual studio by add existing or sth else?

  • metin

    ok now we are getting somewhere it might really be the version or your AppDelegate.h is different, ignore the warnings just post the errors, I’ll post my Appdelegate.h so you can check with yours, check this post in 2 min

    • j

      by the way, i was working with your code from all 6 parts. I just deleted all of that and put just the code from part 1. Now these are my errors:

      Error 3 error C2600: ‘AppDelegate::AppDelegate’ : cannot define a compiler-generated special member function (must be declared in the class first) c:afromanclassesappdelegate.cpp 6 1 Afroman

      Error 4 error C2600: ‘AppDelegate::~AppDelegate’ : cannot define a compiler-generated special member function (must be declared in the class first) c:afromanclassesappdelegate.cpp 10 1 Afroman

      Error 5 error C2039: ‘create’ : is not a member of ‘cocos2d::GLView’ c:afromanclassesappdelegate.cpp 18 1 Afroman

      Error 6 error C3861: ‘create’: identifier not found c:afromanclassesappdelegate.cpp 18 1 Afroman

      • metin

        told you so, and compile after each part :), its also good and important programming practice to compile after few changes to your code

  • j

    I figured it out. My version (3.3) needs GLViewImpl::create() instead of just GLView::create()

    sorry about that

  • Andy

    Thanks for the lovely tutorial. The art assets/resources are not available for download

    • metin

      Re-uploaded. have fun

      • Andy

        Thanks a lot. Time to have fun!

  • mudboy

    Very nice tutorial that got me started cocos2d-x. Works nicely almost as it is given except for some reason I need to have

    glview = GLViewImpl::create("My Game");

    instead of

    glview = GLView::create("My Game");

Recent Posts

Recent Comments