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...