Skip to content

Commit b142dde

Browse files
committed
Merge pull request #150 from hugohuang1111/v3_fw
add framework compile script
2 parents c215b9e + d062eb3 commit b142dde

File tree

117 files changed

+5849
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+5849
-0
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#include "AppDelegate.h"
2+
#include "HelloWorldScene.h"
3+
4+
USING_NS_CC;
5+
6+
AppDelegate::AppDelegate() {
7+
8+
}
9+
10+
AppDelegate::~AppDelegate()
11+
{
12+
}
13+
14+
//if you want a different context,just modify the value of glContextAttrs
15+
//it will takes effect on all platforms
16+
void AppDelegate::initGLContextAttrs()
17+
{
18+
//set OpenGL context attributions,now can only set six attributions:
19+
//red,green,blue,alpha,depth,stencil
20+
GLContextAttrs glContextAttrs = {8, 8, 8, 8, 24, 8};
21+
22+
GLView::setGLContextAttrs(glContextAttrs);
23+
}
24+
25+
bool AppDelegate::applicationDidFinishLaunching() {
26+
// initialize director
27+
auto director = Director::getInstance();
28+
auto glview = director->getOpenGLView();
29+
if(!glview) {
30+
glview = GLViewImpl::createWithRect("HelloCpp", Rect(0, 0, 960, 640));
31+
director->setOpenGLView(glview);
32+
}
33+
34+
director->getOpenGLView()->setDesignResolutionSize(960, 640, ResolutionPolicy::SHOW_ALL);
35+
36+
// turn on display FPS
37+
director->setDisplayStats(true);
38+
39+
// set FPS. the default value is 1.0/60 if you don't call this
40+
director->setAnimationInterval(1.0 / 60);
41+
42+
FileUtils::getInstance()->addSearchPath("res");
43+
44+
// create a scene. it's an autorelease object
45+
auto scene = HelloWorld::createScene();
46+
47+
// run
48+
director->runWithScene(scene);
49+
50+
return true;
51+
}
52+
53+
// This function will be called when the app is inactive. When comes a phone call,it's be invoked too
54+
void AppDelegate::applicationDidEnterBackground() {
55+
Director::getInstance()->stopAnimation();
56+
57+
// if you use SimpleAudioEngine, it must be pause
58+
// SimpleAudioEngine::getInstance()->pauseBackgroundMusic();
59+
}
60+
61+
// this function will be called when the app is active again
62+
void AppDelegate::applicationWillEnterForeground() {
63+
Director::getInstance()->startAnimation();
64+
65+
// if you use SimpleAudioEngine, it must resume here
66+
// SimpleAudioEngine::getInstance()->resumeBackgroundMusic();
67+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#include "HelloWorldScene.h"
2+
#include "cocostudio/CocoStudio.h"
3+
#include "ui/CocosGUI.h"
4+
5+
USING_NS_CC;
6+
7+
using namespace cocostudio::timeline;
8+
9+
Scene* HelloWorld::createScene()
10+
{
11+
// 'scene' is an autorelease object
12+
auto scene = Scene::create();
13+
14+
// 'layer' is an autorelease object
15+
auto layer = HelloWorld::create();
16+
17+
// add layer as a child to scene
18+
scene->addChild(layer);
19+
20+
// return the scene
21+
return scene;
22+
}
23+
24+
// on "init" you need to initialize your instance
25+
bool HelloWorld::init()
26+
{
27+
//////////////////////////////
28+
// 1. super init first
29+
if ( !Layer::init() )
30+
{
31+
return false;
32+
}
33+
34+
auto rootNode = CSLoader::createNode("MainScene.csb");
35+
36+
addChild(rootNode);
37+
38+
return true;
39+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#ifndef __HELLOWORLD_SCENE_H__
2+
#define __HELLOWORLD_SCENE_H__
3+
4+
#include "cocos2d.h"
5+
6+
class HelloWorld : public cocos2d::Layer
7+
{
8+
public:
9+
// there's no 'id' in cpp, so we recommend returning the class instance pointer
10+
static cocos2d::Scene* createScene();
11+
12+
// Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone
13+
virtual bool init();
14+
15+
// implement the "static create()" method manually
16+
CREATE_FUNC(HelloWorld);
17+
};
18+
19+
#endif // __HELLOWORLD_SCENE_H__
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
{
2+
"do_default":{
3+
"exclude_from_template": [
4+
"res-landscape",
5+
"res-portrait"
6+
],
7+
"append_from_template": {
8+
"from": "res-landscape",
9+
"to": ""
10+
},
11+
"project_rename":{
12+
"src_project_name":"HelloCpp",
13+
"files":[
14+
"proj.win32/PROJECT_NAME.vcxproj",
15+
"proj.win32/PROJECT_NAME.vcxproj.filters",
16+
"proj.win32/PROJECT_NAME.vcxproj.user",
17+
"proj.win32/PROJECT_NAME.sln",
18+
"proj.ios_mac/PROJECT_NAME.xcodeproj",
19+
"PROJECT_NAME.ccs",
20+
"PROJECT_NAME.cfg",
21+
"PROJECT_NAME.udf"
22+
]
23+
},
24+
"project_replace_project_name":{
25+
"src_project_name":"HelloCpp",
26+
"files":[
27+
"Classes/AppDelegate.cpp",
28+
"proj.win32/PROJECT_NAME.vcxproj",
29+
"proj.win32/PROJECT_NAME.vcxproj.filters",
30+
"proj.win32/PROJECT_NAME.vcxproj.user",
31+
"proj.win32/PROJECT_NAME.sln",
32+
"PROJECT_NAME.ccs",
33+
"proj.win32/main.cpp",
34+
"proj.android/.project",
35+
"proj.android/.cproject",
36+
"proj.android/AndroidManifest.xml",
37+
"proj.android/build.xml",
38+
"proj.android/res/values/strings.xml",
39+
"proj.ios_mac/ios/main.m",
40+
"proj.ios_mac/ios/Prefix.pch",
41+
"proj.ios_mac/PROJECT_NAME.xcodeproj/project.pbxproj"
42+
]
43+
},
44+
"project_replace_package_name":{
45+
"src_package_name":"org.cocos2dx.hellocpp",
46+
"files":[
47+
"proj.android/AndroidManifest.xml"
48+
]
49+
},
50+
"project_replace_mac_bundleid": {
51+
"src_bundle_id": "org.cocos2dx.hellocpp",
52+
"files": [
53+
"proj.ios_mac/mac/Info.plist"
54+
]
55+
},
56+
"project_replace_ios_bundleid": {
57+
"src_bundle_id": "org.cocos2dx.hellocpp",
58+
"files": [
59+
"proj.ios_mac/ios/Info.plist"
60+
]
61+
}
62+
},
63+
"change_orientation": {
64+
"append_from_template": {
65+
"from": "res-portrait",
66+
"to": ""
67+
},
68+
"modify_files": [
69+
{
70+
"file_path": "Classes/AppDelegate.cpp",
71+
"pattern": "GLViewImpl::createWithRect\\((.*),\\s*Rect\\(\\s*(\\d+),\\s*(\\d+),\\s*(\\d+),\\s*(\\d+)\\)\\)",
72+
"replace_string": "GLViewImpl::createWithRect(\\1, Rect(\\2, \\3, \\5, \\4))"
73+
},
74+
{
75+
"file_path": "Classes/AppDelegate.cpp",
76+
"pattern": "setDesignResolutionSize\\(\\s*(\\d+),\\s*(\\d+),(.*)\\)",
77+
"replace_string": "setDesignResolutionSize(\\2, \\1,\\3)"
78+
},
79+
{
80+
"file_path": "proj.ios_mac/ios/Info.plist",
81+
"pattern": "UIInterfaceOrientationLandscapeRight",
82+
"replace_string": "UIInterfaceOrientationPortrait"
83+
},
84+
{
85+
"file_path": "proj.ios_mac/ios/Info.plist",
86+
"pattern": "UIInterfaceOrientationLandscapeLeft",
87+
"replace_string": "UIInterfaceOrientationPortraitUpsideDown"
88+
},
89+
{
90+
"file_path": "proj.android/AndroidManifest.xml",
91+
"pattern": "android:screenOrientation=\\\".*\\\"",
92+
"replace_string": "android:screenOrientation=\"portrait\""
93+
}
94+
],
95+
"project_rename":{
96+
"src_project_name":"HelloCpp",
97+
"files":[
98+
"PROJECT_NAME.ccs",
99+
"PROJECT_NAME.cfg",
100+
"PROJECT_NAME.udf"
101+
]
102+
},
103+
"project_replace_project_name":{
104+
"src_project_name":"HelloCpp",
105+
"files":[
106+
"PROJECT_NAME.ccs"
107+
]
108+
}
109+
}
110+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
LOCAL_PATH := $(call my-dir)
2+
3+
include $(CLEAR_VARS)
4+
5+
LOCAL_MODULE := cocos2dcpp_shared
6+
7+
LOCAL_MODULE_FILENAME := libcocos2dcpp
8+
9+
LOCAL_SRC_FILES := hellocpp/main.cpp \
10+
../../Classes/AppDelegate.cpp \
11+
../../Classes/HelloWorldScene.cpp
12+
13+
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes
14+
15+
LOCAL_STATIC_LIBRARIES := cocos2dx_static
16+
17+
include $(BUILD_SHARED_LIBRARY)
18+
19+
$(call import-module,./prebuilt-mk)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# This file is automatically generated by Android Tools.
2+
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3+
#
4+
# This file must be checked in Version Control Systems.
5+
#
6+
# To customize properties used by the Ant build system use,
7+
# "ant.properties", and override values to adapt the script to your
8+
# project structure.
9+
10+
# Project target.
11+
target=android-10
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 2013
4+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HelloCpp", "HelloCpp.vcxproj", "{76A39BB2-9B84-4C65-98A5-654D86B86F2A}"
5+
EndProject
6+
Global
7+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
8+
Debug|Win32 = Debug|Win32
9+
Release|Win32 = Release|Win32
10+
EndGlobalSection
11+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
12+
{76A39BB2-9B84-4C65-98A5-654D86B86F2A}.Debug|Win32.ActiveCfg = Debug|Win32
13+
{76A39BB2-9B84-4C65-98A5-654D86B86F2A}.Debug|Win32.Build.0 = Debug|Win32
14+
{76A39BB2-9B84-4C65-98A5-654D86B86F2A}.Release|Win32.ActiveCfg = Release|Win32
15+
{76A39BB2-9B84-4C65-98A5-654D86B86F2A}.Release|Win32.Build.0 = Release|Win32
16+
EndGlobalSection
17+
GlobalSection(SolutionProperties) = preSolution
18+
HideSolutionNode = FALSE
19+
EndGlobalSection
20+
EndGlobal
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include "main.h"
2+
#include "AppDelegate.h"
3+
#include "cocos2d.h"
4+
5+
USING_NS_CC;
6+
7+
#pragma comment(lib,"libcocos2d.lib")
8+
#pragma comment(lib,"libbox2d.lib")
9+
#pragma comment(lib,"libSpine.lib")
10+
11+
int APIENTRY _tWinMain(HINSTANCE hInstance,
12+
HINSTANCE hPrevInstance,
13+
LPTSTR lpCmdLine,
14+
int nCmdShow)
15+
{
16+
UNREFERENCED_PARAMETER(hPrevInstance);
17+
UNREFERENCED_PARAMETER(lpCmdLine);
18+
19+
// create the application instance
20+
AppDelegate app;
21+
return Application::getInstance()->run();
22+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<Solution>
2+
<PropertyGroup Name="HelloCpp" Version="2.1.0.0" Type="CocosStudio" />
3+
<SolutionFolder>
4+
<Group ctype="ResourceGroup">
5+
<RootFolder Name=".">
6+
<Project Name="MainScene.csd" />
7+
<Image Name="HelloWorld.png" />
8+
</RootFolder>
9+
</Group>
10+
</SolutionFolder>
11+
</Solution>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<Properties PublishDirectory="Resources/res" SolutionSize="960 * 640" DefaultSerializer="Serializer_FlatBuffers" CustomSerializer="Serializer_FlatBuffers" />

0 commit comments

Comments
 (0)