Skip to content

Commit

Permalink
Merge pull request #6 from geron-cn/master
Browse files Browse the repository at this point in the history
init based on 3.0
  • Loading branch information
edwardZhang committed Mar 14, 2014
2 parents 81ecf6b + 2e35ce3 commit 84daec4
Show file tree
Hide file tree
Showing 1,342 changed files with 149,416 additions and 0 deletions.
97 changes: 97 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# Ignore CocoStudio Export folder
Backup/
Export/
Ruler/
PList.Dir

# Ignore thumbnails created by windows
Thumbs.db

# Ignore files build by Visual Studio
*.obj
*.exe
*.pdb
*.aps
*.vcproj.*.user
*.vspscc
*_i.c
*.i
*.icf
*_p.c
*.ncb
*.suo
*.tlb
*.tlh
*.bak
*.cache
*.ilk
*.log
[Bb]in
[Dd]ebug*/
*.sbr
*.sdf
obj/
[Rr]elease*/
_ReSharper*/
[Tt]est[Rr]esult*
ipch/
*.opensdf

# Ignore files build by ndk and eclipse
libs/
bin/
obj/
gen/
assets/
local.properties

# Ignore files built by NaCl
samples/Cpp/HelloCpp/proj.nacl/Resources/
samples/Cpp/TestCpp/proj.nacl/Resources/
samples/Cpp/TestCpp/proj.nacl/out/
samples/Cpp/SimpleGame/proj.nacl/Resources/
samples/Lua/HelloLua/proj.nacl/Resources/
samples/Lua/TestLua/proj.nacl/Resources/

# Ignore python compiled files
*.pyc

# Ignore files build by airplay and marmalade
build_*_xcode/
build_*_vc10/

# Ignore files build by xcode
*.mode*v*
*.pbxuser
*.xcbkptlist
*.xcscheme
*.xcworkspacedata
*.xcuserstate
xcschememanagement.plist
build/
.DS_Store
._.*
xcuserdata/
DerivedData/
*.xcworkspace

# Ignore files built by bada
.Simulator-Debug/
.Target-Debug/
.Target-Release/

# Ignore files built by blackberry
Simulator/
Device-Debug/
Device-Release/

# Ignore vim swaps
*.swp

# Ignore config files in javascript bindings generator
tools/tojs/user.cfg
# ... userconf.ini generated if running from tools/tojs
tools/tojs/userconf.ini
# ... userconf.ini generated if running from tools/jenkins_scripts/mac/android/
tools/jenkins_scripts/mac/android/userconf.ini

1 change: 1 addition & 0 deletions DemoBag/cocos2d/readme
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
put cocos2d here what in a project created by create_project.py
1 change: 1 addition & 0 deletions DemoCowboyGame/cocos2d/readme
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
put cocos2d here what in a project created by create_project.py
1 change: 1 addition & 0 deletions DemoFishingJoy/cocos2d/readme
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
put cocos2d here what in a project created by create_project.py
1 change: 1 addition & 0 deletions DemoGameScene/cocos2d/readme
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
put cocos2d here what in a project created by create_project.py
1 change: 1 addition & 0 deletions DemoLogin/cocos2d/readme
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
put cocos2d here what in a project created by create_project.py
169 changes: 169 additions & 0 deletions DemoMap/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
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)

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")

if(USE_CHIPMUNK)
message("Using chipmunk ...")
add_definitions(-DLINUX -DCC_ENABLE_CHIPMUNK_INTEGRATION=1)
elseif(USE_BOX2D)
message("Using box2d ...")
add_definitions(-DLINUX -DCC_ENABLE_BOX2D_INTEGRATION=1)
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()


set(GAME_SRC
proj.linux/main.cpp
Classes/AppDelegate.cpp
Classes/HelloWorldScene.cpp
)

set(COCOS2D_ROOT ${CMAKE_SOURCE_DIR}/cocos2d)

include_directories(
/usr/local/include/GLFW
${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/linux
${COCOS2D_ROOT}/cocos/base
${COCOS2D_ROOT}/cocos/physics
${COCOS2D_ROOT}/cocos/editor-support
${COCOS2D_ROOT}/cocos/math/kazmath/include
${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/chipmunk/include/chipmunk
${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}
)

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}
)

# kazmath
add_subdirectory(${COCOS2D_ROOT}/cocos/math/kazmath)

# chipmunk library
add_subdirectory(${COCOS2D_ROOT}/external/chipmunk/src)

# box2d library
add_subdirectory(${COCOS2D_ROOT}/external/Box2D)

# unzip library
add_subdirectory(${COCOS2D_ROOT}/external/unzip)

# tinyxml2 library
add_subdirectory(${COCOS2D_ROOT}/external/tinyxml2)

# audio
add_subdirectory(${COCOS2D_ROOT}/cocos/audio)

# cocos base library
add_subdirectory(${COCOS2D_ROOT}/cocos/base)

# cocos 2d library
add_subdirectory(${COCOS2D_ROOT}/cocos/2d)

# cocos storage
add_subdirectory(${COCOS2D_ROOT}/cocos/storage)

# gui
add_subdirectory(${COCOS2D_ROOT}/cocos/gui)

# network
add_subdirectory(${COCOS2D_ROOT}/cocos/network)

# 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)

# add the executable
add_executable(${APP_NAME}
${GAME_SRC}
)

if ( CMAKE_SIZEOF_VOID_P EQUAL 8 )
set(FMOD_LIB "fmodex64")
else()
set(FMOD_LIB "fmodex")
endif()

target_link_libraries(${APP_NAME}
gui
network
storage
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}")

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
)

72 changes: 72 additions & 0 deletions DemoMap/Classes/AppDelegate.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#include "AppDelegate.h"
#include "HelloWorldScene.h"
#include "CocosGUIExamplesMapScene.h"

USING_NS_CC;

AppDelegate::AppDelegate() {

}

AppDelegate::~AppDelegate()
{
}

bool AppDelegate::applicationDidFinishLaunching() {
// initialize director
auto director = Director::getInstance();
auto glview = director->getOpenGLView();
if(!glview) {
glview = GLView::create("My Game");
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();

auto designSize = Size(480, 320);

auto fileUtils = FileUtils::getInstance();
std::vector<std::string> searchPaths;

if (screenSize.height > 320)
{
auto resourceSize = Size(960, 640);
searchPaths.push_back("hd");
director->setContentScaleFactor(resourceSize.height/designSize.height);
}

fileUtils->setSearchPaths(searchPaths);

// glview->setDesignResolutionSize(screenSize.width, screenSize.height, ResolutionPolicy::NO_BORDER);
glview->setDesignResolutionSize(designSize.width, designSize.height, ResolutionPolicy::NO_BORDER);

// create a scene. it's an autorelease object
auto scene = new CocosGUIExamplesMapScene();
scene->autorelease();
// 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() {
Director::getInstance()->stopAnimation();

// if you use SimpleAudioEngine, it must be pause
// SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
}

// this function will be called when the app is active again
void AppDelegate::applicationWillEnterForeground() {
Director::getInstance()->startAnimation();

// if you use SimpleAudioEngine, it must resume here
// SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
}
38 changes: 38 additions & 0 deletions DemoMap/Classes/AppDelegate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#ifndef _APP_DELEGATE_H_
#define _APP_DELEGATE_H_

#include "cocos2d.h"

/**
@brief The cocos2d Application.
The reason for implement as private inheritance is to hide some interface call by Director.
*/
class AppDelegate : private cocos2d::Application
{
public:
AppDelegate();
virtual ~AppDelegate();

/**
@brief Implement Director and Scene init code here.
@return true Initialize success, app continue.
@return false Initialize failed, app terminate.
*/
virtual bool applicationDidFinishLaunching();

/**
@brief The function be called when the application enter background
@param the pointer of the application
*/
virtual void applicationDidEnterBackground();

/**
@brief The function be called when the application enter foreground
@param the pointer of the application
*/
virtual void applicationWillEnterForeground();
};

#endif // _APP_DELEGATE_H_

Loading

0 comments on commit 84daec4

Please sign in to comment.