O'Reilly logo

Building Android Games with Cocos2d-x by Raydelto Hernandez

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Putting everything together

This is how our applicationDidFinishLaunching method from our AppDelegate.cpp implementation file looks after we have added the line for including the sounds folder in the resources path:

bool AppDelegate::applicationDidFinishLaunching() {
    auto director = Director::getInstance();
    // OpenGL initialization done by cocos project creation script
    auto glview = director->getOpenGLView();
    if(!glview) {
    glview = GLViewImpl::create("Happy Bunny");
    glview->setFrameSize(480, 800);
    director->setOpenGLView(glview);
   }

   Size screenSize = glview->getFrameSize();
   Size designSize(768, 1280);
   std::vector<std::string> searchPaths;   
   searchPaths.push_back("sounds"); if (screenSize.height > 800){ //High Resolution searchPaths.push_back("images/high"); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required