Book Image

Building Android Games with Cocos2d-x

By : Raydelto Hernandez
Book Image

Building Android Games with Cocos2d-x

By: Raydelto Hernandez

Overview of this book

Table of Contents (16 chapters)
Building Android Games with Cocos2d-x
Credits
Foreword
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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");
      director->setContentScaleFactor(1280.0f / designSize.height);
   }
   else if (screenSize.height > 600){
      //Mid resolution
      searchPaths...