-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
meir yanovich
authored and
meir yanovich
committed
Dec 2, 2014
0 parents
commit ab69730
Showing
4,270 changed files
with
824,810 additions
and
0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,253 @@ | ||
cmake_minimum_required(VERSION 2.6) | ||
|
||
set(APP_NAME MyGame) | ||
project (${APP_NAME}) | ||
|
||
include(cocos2d/build/BuildHelpers.CMakeLists.txt) | ||
|
||
option(USE_CHIPMUNK "Use chipmunk for physics library" ON) | ||
option(USE_BOX2D "Use box2d for physics library" OFF) | ||
option(DEBUG_MODE "Debug or release?" ON) | ||
|
||
if(DEBUG_MODE) | ||
set(CMAKE_BUILD_TYPE DEBUG) | ||
else(DEBUG_MODE) | ||
set(CMAKE_BUILD_TYPE RELEASE) | ||
endif(DEBUG_MODE) | ||
|
||
if (MSVC) | ||
set(CMAKE_C_FLAGS_DEBUG "-DCOCOS2D_DEBUG=1") | ||
set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG}) | ||
|
||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_CRT_SECURE_NO_WARNINGS") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_CRT_SECURE_NO_WARNINGS") | ||
|
||
elseif (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) | ||
set(CMAKE_C_FLAGS_DEBUG "-g -Wall -DCOCOS2D_DEBUG=1") | ||
set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG}) | ||
|
||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") | ||
|
||
endif() | ||
|
||
if(USE_CHIPMUNK) | ||
message("Using chipmunk ...") | ||
add_definitions(-DCC_ENABLE_CHIPMUNK_INTEGRATION=1) | ||
if(UNIX) # assuming linux | ||
add_definitions(-DLINUX ) | ||
endif() | ||
elseif(USE_BOX2D) | ||
message("Using box2d ...") | ||
add_definitions(-DCC_ENABLE_BOX2D_INTEGRATION=1) | ||
if(UNIX) # assuming linux | ||
add_definitions(-DLINUX ) | ||
endif() | ||
else(USE_CHIPMUNK) | ||
message(FATAL_ERROR "Must choose a physics library.") | ||
endif(USE_CHIPMUNK) | ||
|
||
# architecture | ||
if ( CMAKE_SIZEOF_VOID_P EQUAL 8 ) | ||
set(ARCH_DIR "64-bit") | ||
else() | ||
set(ARCH_DIR "32-bit") | ||
endif() | ||
|
||
if( UNIX ) #assume linux | ||
set(GAME_SRC | ||
proj.linux/main.cpp | ||
Classes/AppDelegate.cpp | ||
Classes/HelloWorldScene.cpp | ||
) | ||
elseif ( WIN32 ) | ||
set(GAME_SRC | ||
proj.win32/main.cpp | ||
proj.win32/main.h | ||
proj.win32/resource.h | ||
Classes/AppDelegate.cpp | ||
Classes/HelloWorldScene.cpp | ||
) | ||
endif() | ||
|
||
set(COCOS2D_ROOT ${CMAKE_SOURCE_DIR}/cocos2d) | ||
if (WIN32) | ||
include_directories( | ||
${COCOS2D_ROOT} | ||
${COCOS2D_ROOT}/cocos | ||
${COCOS2D_ROOT}/cocos/audio/include | ||
${COCOS2D_ROOT}/cocos/2d | ||
${COCOS2D_ROOT}/cocos/2d/renderer | ||
${COCOS2D_ROOT}/cocos/2d/platform | ||
${COCOS2D_ROOT}/cocos/2d/platform/desktop | ||
${COCOS2D_ROOT}/cocos/2d/platform/win32 | ||
${COCOS2D_ROOT}/cocos/base | ||
${COCOS2D_ROOT}/cocos/deprecated | ||
${COCOS2D_ROOT}/cocos/physics | ||
${COCOS2D_ROOT}/cocos/editor-support | ||
${COCOS2D_ROOT}/cocos/math | ||
${COCOS2D_ROOT}/extensions | ||
${COCOS2D_ROOT}/external | ||
${COCOS2D_ROOT}/external/edtaa3func | ||
${COCOS2D_ROOT}/external/jpeg/include/win32 | ||
${COCOS2D_ROOT}/external/png/include/win32 | ||
${COCOS2D_ROOT}/external/tiff/include/win32 | ||
${COCOS2D_ROOT}/external/webp/include/win32 | ||
${COCOS2D_ROOT}/external/curl/include/win32 | ||
${COCOS2D_ROOT}/external/tinyxml2 | ||
${COCOS2D_ROOT}/external/unzip | ||
${COCOS2D_ROOT}/external/sqlite3/include | ||
${COCOS2D_ROOT}/external/chipmunk/include/chipmunk | ||
${COCOS2D_ROOT}/external/freetype2/include/win32 | ||
${COCOS2D_ROOT}/external/websockets/include/win32 | ||
${COCOS2D_ROOT}/external/spidermonkey/include/win32 | ||
${COCOS2D_ROOT}/external/glfw3/include/win32 | ||
${COCOS2D_ROOT}/external/win32-specific/gles/include/OGLES | ||
${COCOS2D_ROOT}/external/win32-specific/icon/include | ||
${COCOS2D_ROOT}/external/win32-specific/zlib/include | ||
${COCOS2D_ROOT}/external/xxhash | ||
) | ||
link_directories( | ||
/usr/local/lib | ||
${COCOS2D_ROOT}/external/png/prebuilt/win32 | ||
${COCOS2D_ROOT}/external/jpeg/prebuilt/win32 | ||
${COCOS2D_ROOT}/external/tiff/prebuilt/win32 | ||
${COCOS2D_ROOT}/external/glfw3/prebuilt/win32 | ||
${COCOS2D_ROOT}/external/webp/prebuilt/win32 | ||
${COCOS2D_ROOT}/external/curl/prebuilt/win32 | ||
${COCOS2D_ROOT}/external/sqlite3/libraries/win32 | ||
${COCOS2D_ROOT}/external/freetype2/prebuilt/win32 | ||
${COCOS2D_ROOT}/external/websockets/prebuilt/win32 | ||
${COCOS2D_ROOT}/external/spidermonkey/prebuilt/win32 | ||
${COCOS2D_ROOT}/external/win32-specific/gles/prebuilt | ||
${COCOS2D_ROOT}/external/win32-specific/icon/prebuilt | ||
${COCOS2D_ROOT}/external/win32-specific/zlib/prebuilt | ||
) | ||
|
||
elseif(UNIX) #assumed linux | ||
include_directories( | ||
/usr/local/include/GLFW | ||
/usr/include/GLFW | ||
${COCOS2D_ROOT} | ||
${COCOS2D_ROOT}/cocos | ||
${COCOS2D_ROOT}/cocos/audio/include | ||
${COCOS2D_ROOT}/cocos/platform | ||
${COCOS2D_ROOT}/cocos/platform/desktop | ||
${COCOS2D_ROOT}/cocos/platform/linux | ||
${COCOS2D_ROOT}/cocos/editor-support | ||
${COCOS2D_ROOT}/extensions | ||
${COCOS2D_ROOT}/external | ||
${COCOS2D_ROOT}/external/edtaa3func | ||
${COCOS2D_ROOT}/external/jpeg/include/linux | ||
${COCOS2D_ROOT}/external/tiff/include/linux | ||
${COCOS2D_ROOT}/external/webp/include/linux | ||
${COCOS2D_ROOT}/external/tinyxml2 | ||
${COCOS2D_ROOT}/external/unzip | ||
${COCOS2D_ROOT}/external/freetype2/include/linux | ||
${COCOS2D_ROOT}/external/websockets/include/linux | ||
${COCOS2D_ROOT}/external/spidermonkey/include/linux | ||
${COCOS2D_ROOT}/external/linux-specific/fmod/include/${ARCH_DIR} | ||
${COCOS2D_ROOT}/external/xxhash | ||
) | ||
|
||
link_directories( | ||
/usr/local/lib | ||
${COCOS2D_ROOT}/external/jpeg/prebuilt/linux/${ARCH_DIR} | ||
${COCOS2D_ROOT}/external/tiff/prebuilt/linux/${ARCH_DIR} | ||
${COCOS2D_ROOT}/external/webp/prebuilt/linux/${ARCH_DIR} | ||
${COCOS2D_ROOT}/external/freetype2/prebuilt/linux/${ARCH_DIR} | ||
${COCOS2D_ROOT}/external/websockets/prebuilt/linux/${ARCH_DIR} | ||
${COCOS2D_ROOT}/external/spidermonkey/prebuilt/linux/${ARCH_DIR} | ||
${COCOS2D_ROOT}/external/linux-specific/fmod/prebuilt/${ARCH_DIR} | ||
) | ||
endif() | ||
|
||
if(USE_CHIPMUNK) | ||
|
||
include_directories(${COCOS2D_ROOT}/external/chipmunk/include/chipmunk) | ||
# chipmunk library | ||
add_subdirectory(${COCOS2D_ROOT}/external/chipmunk/src) | ||
endif() | ||
|
||
if(USE_BOX2D) | ||
# box2d library | ||
add_subdirectory(${COCOS2D_ROOT}/external/Box2D) | ||
endif() | ||
|
||
# unzip library | ||
add_subdirectory(${COCOS2D_ROOT}/external/unzip) | ||
|
||
# tinyxml2 library | ||
add_subdirectory(${COCOS2D_ROOT}/external/tinyxml2) | ||
|
||
# audio | ||
add_subdirectory(${COCOS2D_ROOT}/cocos/audio) | ||
|
||
# xxhash library | ||
add_subdirectory(${COCOS2D_ROOT}/external/xxhash) | ||
|
||
# cocos2d | ||
add_subdirectory(${COCOS2D_ROOT}/cocos) | ||
|
||
# extensions | ||
add_subdirectory(${COCOS2D_ROOT}/extensions) | ||
|
||
## Editor Support | ||
|
||
# spine | ||
add_subdirectory(${COCOS2D_ROOT}/cocos/editor-support/spine) | ||
|
||
# cocosbuilder | ||
add_subdirectory(${COCOS2D_ROOT}/cocos/editor-support/cocosbuilder) | ||
|
||
# cocostudio | ||
add_subdirectory(${COCOS2D_ROOT}/cocos/editor-support/cocostudio) | ||
|
||
if ( WIN32 ) | ||
# add the executable | ||
add_executable(${APP_NAME} | ||
WIN32 | ||
${GAME_SRC} | ||
) | ||
else() | ||
# add the executable | ||
add_executable(${APP_NAME} | ||
${GAME_SRC} | ||
) | ||
endif() | ||
|
||
if ( CMAKE_SIZEOF_VOID_P EQUAL 8 ) | ||
set(FMOD_LIB "fmodex64") | ||
else() | ||
set(FMOD_LIB "fmodex") | ||
endif() | ||
|
||
target_link_libraries(${APP_NAME} | ||
spine | ||
cocostudio | ||
cocosbuilder | ||
extensions | ||
audio | ||
cocos2d | ||
) | ||
|
||
set(APP_BIN_DIR "${CMAKE_BINARY_DIR}/bin") | ||
|
||
set_target_properties(${APP_NAME} PROPERTIES | ||
RUNTIME_OUTPUT_DIRECTORY "${APP_BIN_DIR}") | ||
|
||
if ( WIN32 ) | ||
#also copying dlls to binary directory for the executable to run | ||
pre_build(${APP_NAME} | ||
COMMAND ${CMAKE_COMMAND} -E remove_directory ${APP_BIN_DIR}/Resources | ||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/Resources ${APP_BIN_DIR}/Resources | ||
COMMAND ${CMAKE_COMMAND} -E copy ${COCOS2D_ROOT}/external/win32-specific/gles/prebuilt/glew32.dll ${APP_BIN_DIR}/${CMAKE_BUILD_TYPE} | ||
COMMAND ${CMAKE_COMMAND} -E copy ${COCOS2D_ROOT}/external/win32-specific/zlib/prebuilt/zlib1.dll ${APP_BIN_DIR}/${CMAKE_BUILD_TYPE} | ||
) | ||
else() | ||
pre_build(${APP_NAME} | ||
COMMAND ${CMAKE_COMMAND} -E remove_directory ${APP_BIN_DIR}/Resources | ||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/Resources ${APP_BIN_DIR}/Resources | ||
) | ||
|
||
endif() |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
#include "AppDelegate.h" | ||
#include "HelloWorldScene.h" | ||
#include "SimpleAudioEngine.h" | ||
#include "Settings.h" | ||
//#include "config/ConstAppDefine.h" | ||
|
||
#if defined(USE_FACEBOOK_INTEGRATION) | ||
#include "screw/screw.h" | ||
#include "screw/Notification.h" | ||
USING_NS_SCREW_FACEBOOK; | ||
#endif | ||
|
||
|
||
AppDelegate::AppDelegate() { | ||
|
||
} | ||
|
||
AppDelegate::~AppDelegate() | ||
{ | ||
core::Settings::destroyInstance(); | ||
CocosDenshion::SimpleAudioEngine::end(); | ||
} | ||
|
||
bool AppDelegate::applicationDidFinishLaunching() { | ||
|
||
#if defined(USE_FACEBOOK_INTEGRATION) | ||
screw::facebook::Session::start(); | ||
#endif | ||
|
||
|
||
|
||
// initialize director | ||
auto director = cocos2d::Director::getInstance(); | ||
auto glview = director->getOpenGLView(); | ||
if(!glview) { | ||
//glview = cocos2d::GLView::createWithRect(APP_NAME, Rect(0, 0, 640, 960)); | ||
glview = GLView::create(APP_NAME); | ||
//glview->setFrameSize(640, 1136); | ||
glview->setFrameSize(640, 960); | ||
director->setOpenGLView(glview); | ||
} | ||
|
||
// turn on display FPS | ||
//director->setDisplayStats(true); | ||
|
||
// set FPS. the default value is 1.0/60 if you don't call this | ||
director->setAnimationInterval(1.0 / 60); | ||
auto screenSize = glview->getFrameSize(); | ||
#if defined(USE_FACEBOOK_INTEGRATION) | ||
Facebook::getInstance()->start(); | ||
director->setNotificationNode(Notification::getInstance()); | ||
#endif | ||
cocos2d::FileUtils* fileUtils = cocos2d::FileUtils::getInstance(); | ||
std::vector<std::string> searchPaths; | ||
ResolutionPolicy resolutionPolicy = ResolutionPolicy::NO_BORDER;//ResolutionPolicy::SHOW_ALL; | ||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) | ||
glview->setFrameZoomFactor(0.5f); | ||
#endif | ||
if (screenSize.width == 2048 || screenSize.height == 2048) | ||
{ | ||
glview->setDesignResolutionSize(1536, 2048,resolutionPolicy); | ||
searchPaths.push_back("ipadhd"); | ||
searchPaths.push_back("ipadsd"); | ||
searchPaths.push_back("iphone5"); | ||
searchPaths.push_back("iphonehd"); | ||
searchPaths.push_back("iphonesd"); | ||
} | ||
else if (screenSize.width == 1024 || screenSize.height == 1024) | ||
{ | ||
glview->setDesignResolutionSize(768, 1024,resolutionPolicy); | ||
searchPaths.push_back("ipadsd"); | ||
searchPaths.push_back("iphone5"); | ||
searchPaths.push_back("iphonehd"); | ||
searchPaths.push_back("iphonesd"); | ||
|
||
} | ||
else if (screenSize.width == 1136 || screenSize.height == 1136) | ||
{ | ||
glview->setDesignResolutionSize(640, 1136,resolutionPolicy); | ||
searchPaths.push_back("iphone5"); | ||
//searchPaths.push_back("iphonehd"); | ||
//searchPaths.push_back("iphonesd"); | ||
|
||
} | ||
else if (screenSize.width == 960 || screenSize.height == 960) | ||
{ | ||
glview->setDesignResolutionSize(640, 960,resolutionPolicy); | ||
searchPaths.push_back("iphonehd"); | ||
searchPaths.push_back("iphonesd"); | ||
} | ||
else | ||
{ | ||
searchPaths.push_back("iphonesd"); | ||
glview->setDesignResolutionSize(320, 480,resolutionPolicy); | ||
} | ||
|
||
fileUtils->setSearchPaths(searchPaths); | ||
|
||
// create a scene. it's an autorelease object | ||
auto scene = HelloWorld::createScene(); | ||
|
||
// run | ||
director->runWithScene(scene); | ||
|
||
return true; | ||
} | ||
|
||
// This function will be called when the app is inactive. When comes a phone call,it's be invoked too | ||
void AppDelegate::applicationDidEnterBackground() { | ||
CocosDenshion::SimpleAudioEngine::getInstance()->pauseAllEffects(); | ||
CocosDenshion::SimpleAudioEngine::getInstance()->pauseBackgroundMusic(); | ||
cocos2d::Director::getInstance()->stopAnimation(); | ||
|
||
|
||
// if you use SimpleAudioEngine, it must be pause | ||
// SimpleAudioEngine::getInstance()->pauseBackgroundMusic(); | ||
} | ||
|
||
// this function will be called when the app is active again | ||
void AppDelegate::applicationWillEnterForeground() { | ||
CocosDenshion::SimpleAudioEngine::getInstance()->resumeAllEffects(); | ||
CocosDenshion::SimpleAudioEngine::getInstance()->resumeBackgroundMusic(); | ||
|
||
cocos2d::Director::getInstance()->startAnimation(); | ||
|
||
|
||
// if you use SimpleAudioEngine, it must resume here | ||
// SimpleAudioEngine::getInstance()->resumeBackgroundMusic(); | ||
} |
Oops, something went wrong.