Skip to content

Commit 310d717

Browse files
authored
Merge pull request #18 from cocos2d/v4
Sync with master
2 parents 3b19ecc + 8214f27 commit 310d717

File tree

495 files changed

+8217
-19145
lines changed

Some content is hidden

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

495 files changed

+8217
-19145
lines changed

.travis.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,16 @@ matrix:
5656
env: BUILD_TARGET=linux_cocos_new_test
5757
language: cpp
5858
sudo: required
59+
- os: osx
60+
env: BUILD_TARGET=ios_cocos_new_lua_test
61+
language: cpp
62+
osx_image: xcode11
63+
sudo: required
64+
- os: osx
65+
env: BUILD_TARGET=ios_cocos_new_cpp_test
66+
language: cpp
67+
osx_image: xcode11
68+
sudo: required
5969

6070
script:
6171
- tools/travis-scripts/run-script.sh

CHANGELOG

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
1-
cocos2d-x-4.0 ??
1+
cocos2d-x-4.0 Dec.3 2019
22

33
[HIGHLIGHT] Support metal
44
[HIGHLIGHT] Use CMake for all platforms
55

66
[REFINE] Update glfw to 3.3
7+
[REFINE] Update minizip to 1.2
78

89
[CHANGE] remove deprecated functions
910
[CHANGE] remove h5 engine and JSB
1011
[CHANGE] remove tiff
12+
[CHANGE] remove `experimental` namespace
13+
14+
[FIX] system font can not work correctly on macOS 15
15+
[FIX] TextField can not work if using system input to get Chinese characters with iOS13
16+
[FIX] UIWebView uses WKWebView instead
17+
[FIX] VideoPlayer uses AVPlayerController instead
18+
[FX] lua crashes on 64it devcices
1119

1220
cocos2d-x-3.17 May.21 2018
1321

CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ cmake_minimum_required(VERSION 3.6)
3030

3131
project(Cocos2d-x)
3232

33+
# set default minimum deployment target
34+
if(XCODE)
35+
if(NOT DEFINED CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET)
36+
SET (CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET 8.0)
37+
endif()
38+
endif()
39+
3340
# cocos2dx root path
3441
set(COCOS2DX_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR})
3542
set(CMAKE_MODULE_PATH ${COCOS2DX_ROOT_PATH}/cmake/Modules/)

README.md

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ cocos2d-x
66

77
|Win32|Others|
88
| ----|------|
9-
[![Build status](https://ci.appveyor.com/api/projects/status/nlgirox464j6ldg5/branch/v3?svg=true)](https://ci.appveyor.com/project/minggo/cocos2d-x/branch/v3)|[![Build Status](https://travis-ci.org/cocos2d/cocos2d-x.svg?branch=v3)](https://travis-ci.org/cocos2d/cocos2d-x)
9+
[![Build status](https://ci.appveyor.com/api/projects/status/nlgirox464j6ldg5/branch/v4?svg=true)](https://ci.appveyor.com/project/minggo/cocos2d-x/branch/v4)|[![Build Status](https://travis-ci.org/cocos2d/cocos2d-x.svg?branch=v4)](https://travis-ci.org/cocos2d/cocos2d-x)
1010

1111

1212
[cocos2d-x][1] is a multi-platform framework for building 2d games, interactive books, demos and other graphical applications.
13-
It is based on [cocos2d-iphone][2], but instead of using Objective-C, it uses C++.
14-
It works on iOS, Android, OS X, Windows and Linux.
13+
It is based on __cocos2d-iphone__, but instead of using Objective-C, it uses C++.
14+
It works on iOS, Android, macOS, Windows and Linux.
1515

1616
**Cocos2d-x Framework Architecture**:
1717

@@ -47,11 +47,11 @@ Download stable versions
4747

4848
Documentations and samples
4949
-------------
50-
* [All Docs in a single place!](http://cocos2d-x.org/docs/)
51-
* [Online API Reference](http://cocos2d-x.org/docs/api-ref/index.html) _Note that Cocos2d-x and Cocos Creator have different API set_
52-
* [Programmers Guide](http://cocos2d-x.org/docs/programmers-guide/2/index.html)
53-
* [Latest Release Note](https://github.com/cocos2d/cocos2d-x/blob/v3/docs/RELEASE_NOTES.md)
54-
* [Changelog](https://github.com/cocos2d/cocos2d-x/blob/v3/CHANGELOG)
50+
* [All Docs in a single place!](http://docs.cocos2d-x.org/)
51+
* [Online API Reference](http://docs.cocos2d-x.org/api-ref/index.html) _Note that Cocos2d-x and Cocos Creator have different API set_
52+
* [Programmers Guide](https://docs.cocos2d-x.org/cocos2d-x/v4/en/basic_concepts/)
53+
* [Latest Release Note](https://github.com/cocos2d/cocos2d-x/blob/v4/docs/RELEASE_NOTES.md)
54+
* [Changelog](https://github.com/cocos2d/cocos2d-x/blob/v4/CHANGELOG)
5555

5656
Main features
5757
-------------
@@ -156,12 +156,10 @@ For Android, the Android Studio project file lies in `PROJECT_DIR/proj.android`.
156156
Learning Resources
157157
--------------------------------
158158

159-
* [Programmers Guide](http://cocos2d-x.org/docs/programmers-guide/2/index.html)
160-
* [Sonar Systems Videos](https://www.youtube.com/user/sonarsystemslimited/search?query=cocos2d-x)
159+
* [Programmers Guide](https://docs.cocos2d-x.org/cocos2d-x/v4/en/basic_concepts/)
161160
* [Android Fundamentals](https://developer.android.com/guide/components/fundamentals.html)
162-
* [Make School Tutorials](https://www.makeschool.com/tutorials/)
163161
* [Games From Scratch](http://www.gamefromscratch.com/page/Cocos2d-x-CPP-Game-Programming-Tutorial-Series.aspx)
164-
* [Cocos2d sample games](https://github.com/cocos2d/cocos2d-x-samples)
162+
* [Make School Tutorials](https://github.com/MakeSchool?utf8=✓&q=cocos2d&type=&language=)
165163

166164
Spreading the word!
167165
--------------------------------
@@ -170,24 +168,17 @@ You can help us spread the word about cocos2d-x! We would surely appreciate it!
170168
* Talk about us on Facebook! Our [Facebook Page](https://www.facebook.com/cocos2dx/)
171169
* Tweet, Tweet! Our [Twitter](https://twitter.com/cocos2dx)
172170
* Read our [Blog](http://blog.cocos2d-x.org/) and promote it on your social media.
173-
* Become a [Regional Coordinator](http://discuss.cocos2d-x.org/t/we-need-regional-coordinators/24104)
174-
175-
See what we are planning!
176-
--------------------------------
177-
You can see exactly what we are planning to do with the Cocos family of products.
178-
179-
* [Cocos2d-x roadmap](https://trello.com/b/Np6obnuE/cocos2d-x-roadmap)
180171

181172
Where to get help
182173
--------------------------------
183174

184175
* [English Forums](http://discuss.cocos2d-x.org)
185176
* [中文社区](http://forum.cocos.com/c/cocos2d-x)
186177
* [Bug Tracker](https://github.com/cocos2d/cocos2d-x/issues)
187-
* [API Reference](http://cocos2d-x.org/docs/api-ref/index.html).
188-
* [Latest Release Note](https://github.com/cocos2d/cocos2d-x/blob/v3/docs/RELEASE_NOTES.md)
189-
* [Changelog](https://github.com/cocos2d/cocos2d-x/blob/v3/CHANGELOG)
190-
* IRC. We are in [Freenode](https://webchat.freenode.net/) in the _#cocos2d_ channel
178+
* [API Reference](http://docs.cocos2d-x.org/api-ref/index.html).
179+
* [Latest Release Note](https://github.com/cocos2d/cocos2d-x/blob/v4/docs/RELEASE_NOTES.md)
180+
* [Changelog](https://github.com/cocos2d/cocos2d-x/blob/v4/CHANGELOG)
181+
* [Discord Channel](https://discord.gg/pVqab4K)
191182
* `cpp-tests` project. This project is our basis for testing. Use this project to
192183
learn how we implement the functionality of the engine. This project is located in
193184
__cocos2d-x_root/build.__
@@ -209,8 +200,6 @@ Contact us
209200
* Weibo: [http://t.sina.com.cn/cocos2dx][11]
210201

211202
[1]: http://www.cocos2d-x.org "cocos2d-x"
212-
[2]: http://www.cocos2d-iphone.org "cocos2d for iPhone"
213-
[3]: http://www.cocos2d-x.org/projects/cocos2d-x/wiki/Download
214203
[4]: http://www.cocos2d-x.org/download/version#Cocos2d-x
215204
[5]: http://www.box2d.org "Box2D"
216205
[6]: http://www.chipmunk-physics.net "Chipmunk2D"

cmake/Modules/CocosBuildHelpers.cmake

Lines changed: 78 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,81 @@ include(CMakeParseArguments)
22

33
# copy resource `FILES` and `FOLDERS` to TARGET_FILE_DIR/Resources
44
function(cocos_copy_target_res cocos_target)
5-
set(oneValueArgs COPY_TO)
6-
set(multiValueArgs FILES FOLDERS)
5+
set(oneValueArgs LINK_TO)
6+
set(multiValueArgs FOLDERS)
77
cmake_parse_arguments(opt "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
8-
# copy files
9-
foreach(cc_file ${opt_FILES})
10-
get_filename_component(file_name ${cc_file} NAME)
11-
add_custom_command(TARGET ${cocos_target} POST_BUILD
12-
#COMMAND ${CMAKE_COMMAND} -E echo "copy-file into Resources: ${file_name} ..."
13-
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${cc_file} "${opt_COPY_TO}/${file_name}"
8+
9+
if(NOT TARGET SYNC_RESOURCE-${cocos_target})
10+
message(WARNING "SyncResource targe for ${cocos_target} is not defined")
11+
return()
12+
endif()
13+
14+
# linking folders
15+
foreach(cc_folder ${opt_FOLDERS})
16+
#get_filename_component(link_folder ${opt_LINK_TO} DIRECTORY)
17+
get_filename_component(link_folder_abs ${opt_LINK_TO} ABSOLUTE)
18+
add_custom_command(TARGET SYNC_RESOURCE-${cocos_target} POST_BUILD
19+
COMMAND ${CMAKE_COMMAND} -E echo " copying to ${link_folder_abs}"
20+
COMMAND ${PYTHON_COMMAND} ARGS ${COCOS2DX_ROOT_PATH}/cmake/scripts/sync_folder.py
21+
-s ${cc_folder} -d ${link_folder_abs}
1422
)
1523
endforeach()
16-
# copy folders files
17-
foreach(cc_folder ${opt_FOLDERS})
18-
# file(GLOB_RECURSE folder_files "${cc_folder}/*")
19-
# get_filename_component(folder_abs_path ${cc_folder} ABSOLUTE)
20-
# foreach(res_file ${folder_files})
21-
# get_filename_component(res_file_abs_path ${res_file} ABSOLUTE)
22-
# file(RELATIVE_PATH res_file_relat_path ${folder_abs_path} ${res_file_abs_path})
23-
# add_custom_command(TARGET ${cocos_target} POST_BUILD
24-
# COMMAND ${CMAKE_COMMAND} -E echo "copy file into Resources: ${res_file_relat_path} ..."
25-
# COMMAND ${CMAKE_COMMAND} -E copy_if_different ${res_file} "${opt_COPY_TO}/${res_file_relat_path}"
26-
# )
27-
# endforeach()
28-
### copy file by file is too slow on windows, the copy_directory improves a lot.
29-
add_custom_command(TARGET ${cocos_target} POST_BUILD
30-
#COMMAND ${CMAKE_COMMAND} -E echo "copy-dir into Resources: ${opt_COPY_TO} ..."
31-
COMMAND ${CMAKE_COMMAND} -E copy_directory ${cc_folder} "${opt_COPY_TO}"
24+
endfunction()
25+
26+
## create a virtual target SYNC_RESOURCE-${cocos_target}
27+
## Update resource files in Resources/ folder everytime when `Run/Debug` target.
28+
function(cocos_def_copy_resource_target cocos_target)
29+
add_custom_target(SYNC_RESOURCE-${cocos_target} ALL
30+
COMMAND ${CMAKE_COMMAND} -E echo "Copying resources for ${cocos_target} ..."
31+
)
32+
add_dependencies(${cocos_target} SYNC_RESOURCE-${cocos_target})
33+
set_target_properties(SYNC_RESOURCE-${cocos_target} PROPERTIES
34+
FOLDER Utils
35+
)
36+
endfunction()
37+
38+
39+
function(cocos_copy_lua_scripts cocos_target src_dir dst_dir)
40+
set(luacompile_target COPY_LUA-${cocos_target})
41+
if(NOT TARGET ${luacompile_target})
42+
add_custom_target(${luacompile_target} ALL
43+
COMMAND ${CMAKE_COMMAND} -E echo "Copying lua scripts ..."
44+
)
45+
add_dependencies(${cocos_target} ${luacompile_target})
46+
set_target_properties(${luacompile_target} PROPERTIES
47+
FOLDER Utils
48+
)
49+
endif()
50+
if(MSVC)
51+
add_custom_command(TARGET ${luacompile_target} POST_BUILD
52+
COMMAND ${PYTHON_COMMAND} ARGS ${COCOS2DX_ROOT_PATH}/cmake/scripts/sync_folder.py
53+
-s ${src_dir} -d ${dst_dir} -l ${LUAJIT32_COMMAND} -m $<CONFIG>
54+
)
55+
else()
56+
if("${CMAKE_BUILD_TYPE}" STREQUAL "")
57+
add_custom_command(TARGET ${luacompile_target} POST_BUILD
58+
COMMAND ${PYTHON_COMMAND} ARGS ${COCOS2DX_ROOT_PATH}/cmake/scripts/sync_folder.py
59+
-s ${src_dir} -d ${dst_dir}
3260
)
33-
endforeach()
61+
else()
62+
add_custom_command(TARGET ${luacompile_target} POST_BUILD
63+
COMMAND ${PYTHON_COMMAND} ARGS ${COCOS2DX_ROOT_PATH}/cmake/scripts/sync_folder.py
64+
-s ${src_dir} -d ${dst_dir} -l ${LUAJIT32_COMMAND} -m ${CMAKE_BUILD_TYPE}
65+
COMMAND ${PYTHON_COMMAND} ARGS ${COCOS2DX_ROOT_PATH}/cmake/scripts/sync_folder.py
66+
-s ${src_dir} -d ${dst_dir}/64bit -l ${LUAJIT64_COMMAND} -m ${CMAKE_BUILD_TYPE}
67+
)
68+
endif()
69+
endif()
70+
3471
endfunction()
3572

73+
74+
function(cocos_get_resource_path output cocos_target)
75+
get_target_property(rt_output ${cocos_target} RUNTIME_OUTPUT_DIRECTORY)
76+
set(${output} "${rt_output}/${CMAKE_CFG_INTDIR}/Resources" PARENT_SCOPE)
77+
endfunction()
78+
79+
3680
# mark `FILES` and files in `FOLDERS` as resource files, the destination is `RES_TO` folder
3781
# save all marked files in `res_out`
3882
function(cocos_mark_multi_resources res_out)
@@ -202,6 +246,15 @@ function(setup_cocos_app_config app_name)
202246
if(XCODE OR VS)
203247
cocos_mark_code_files(${app_name})
204248
endif()
249+
250+
if (XCODE)
251+
cocos_config_app_xcode_property(${app_name})
252+
endif()
253+
254+
if(LINUX OR WINDOWS)
255+
cocos_def_copy_resource_target(${app_name})
256+
endif()
257+
205258
endfunction()
206259

207260
# if cc_variable not set, then set it cc_value
@@ -211,52 +264,6 @@ macro(cocos_set_default_value cc_variable cc_value)
211264
endif()
212265
endmacro()
213266

214-
# generate macOS app package infomations, need improve for example, the using of info.plist
215-
function(cocos_pak_xcode cocos_target)
216-
set(oneValueArgs
217-
INFO_PLIST
218-
BUNDLE_NAME
219-
BUNDLE_VERSION
220-
COPYRIGHT
221-
GUI_IDENTIFIER
222-
ICON_FILE
223-
INFO_STRING
224-
LONG_VERSION_STRING
225-
SHORT_VERSION_STRING
226-
)
227-
set(multiValueArgs)
228-
cmake_parse_arguments(ARGS "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
229-
230-
string(TIMESTAMP ARGS_COPYRIGHT_YEAR "%Y")
231-
# set default value
232-
cocos_set_default_value(ARGS_INFO_PLIST "MacOSXBundleInfo.plist.in")
233-
cocos_set_default_value(ARGS_BUNDLE_NAME "\${PRODUCT_NAME}")
234-
cocos_set_default_value(ARGS_BUNDLE_VERSION "1")
235-
cocos_set_default_value(ARGS_COPYRIGHT "Copyright © ${ARGS_COPYRIGHT_YEAR}. All rights reserved.")
236-
cocos_set_default_value(ARGS_GUI_IDENTIFIER "org.cocos2dx.${APP_NAME}")
237-
cocos_set_default_value(ARGS_ICON_FILE "Icon")
238-
cocos_set_default_value(ARGS_INFO_STRING "cocos2d-x app")
239-
cocos_set_default_value(ARGS_LONG_VERSION_STRING "1.0.0")
240-
cocos_set_default_value(ARGS_SHORT_VERSION_STRING "1.0")
241-
# set default values for Info.plist template
242-
set_target_properties(${cocos_target}
243-
PROPERTIES
244-
MACOSX_BUNDLE_INFO_PLIST ${ARGS_INFO_PLIST}
245-
)
246-
set(MACOSX_BUNDLE_BUNDLE_NAME ${ARGS_BUNDLE_NAME} PARENT_SCOPE)
247-
set(MACOSX_BUNDLE_BUNDLE_VERSION ${ARGS_BUNDLE_VERSION} PARENT_SCOPE)
248-
set(MACOSX_BUNDLE_COPYRIGHT ${ARGS_COPYRIGHT} PARENT_SCOPE)
249-
set(MACOSX_BUNDLE_GUI_IDENTIFIER ${ARGS_GUI_IDENTIFIER} PARENT_SCOPE)
250-
set(MACOSX_BUNDLE_ICON_FILE ${ARGS_ICON_FILE} PARENT_SCOPE)
251-
set(MACOSX_BUNDLE_INFO_STRING ${ARGS_INFO_STRING} PARENT_SCOPE)
252-
set(MACOSX_BUNDLE_LONG_VERSION_STRING ${ARGS_LONG_VERSION_STRING} PARENT_SCOPE)
253-
set(MACOSX_BUNDLE_SHORT_VERSION_STRING ${ARGS_SHORT_VERSION_STRING} PARENT_SCOPE)
254-
255-
message(STATUS "cocos package: ${cocos_target}, plist file: ${ARGS_INFO_PLIST}")
256-
257-
cocos_config_app_xcode_property(${cocos_target})
258-
endfunction()
259-
260267
# set Xcode property for application, include all depend target
261268
macro(cocos_config_app_xcode_property cocos_app)
262269
set(depend_libs)
@@ -271,7 +278,6 @@ endmacro()
271278
# custom Xcode property for iOS target
272279
macro(cocos_config_target_xcode_property cocos_target)
273280
if(IOS)
274-
set_xcode_property(${cocos_target} IPHONEOS_DEPLOYMENT_TARGET "8.0")
275281
set_xcode_property(${cocos_target} ENABLE_BITCODE "NO")
276282
set_xcode_property(${cocos_target} ONLY_ACTIVE_ARCH "YES")
277283
endif()
@@ -368,4 +374,3 @@ function(cocos_use_pkg target pkg)
368374
endif()
369375

370376
endfunction()
371-

cmake/Modules/CocosBuildSet.cmake

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,21 @@ if(CMAKE_TOOLCHAIN_FILE)
1414
message(STATUS "using toolchain file:" ${CMAKE_TOOLCHAIN_FILE})
1515
endif()
1616

17+
find_program(PYTHON_COMMAND NAMES python2 python)
18+
find_program(COCOS_COMMAND NAME cocos
19+
PATHS ${COCOS2DX_ROOT_PATH}/tools/cocos2d-console/bin $ENV{COCOS_CONSOLE_ROOT})
20+
1721
message(STATUS "PROJECT_NAME:" ${PROJECT_NAME})
1822
message(STATUS "PROJECT_SOURCE_DIR:" ${PROJECT_SOURCE_DIR})
1923
message(STATUS "COCOS2DX_ROOT_PATH:" ${COCOS2DX_ROOT_PATH})
2024
message(STATUS "CMAKE_MODULE_PATH:" ${CMAKE_MODULE_PATH})
2125
# delete binary dir if you hope a full clean re-build
2226
message(STATUS "PROJECT_BINARY_DIR:" ${PROJECT_BINARY_DIR})
2327
message(STATUS "ENGINE_BINARY_PATH:" ${ENGINE_BINARY_PATH})
24-
28+
message(STATUS "PYTHON_PATH:" ${PYTHON_COMMAND})
29+
message(STATUS "COCOS_COMMAND_PATH:" ${COCOS_COMMAND})
30+
message(STATUS "HOST_SYSTEM:" ${CMAKE_HOST_SYSTEM_NAME})
2531
# the default behavior of build module
26-
option(DEBUG_MODE "Debug or Release?" ON)
2732
option(BUILD_LUA_LIBS "Build lua libraries" OFF)
2833

2934
# include helper functions
@@ -36,3 +41,22 @@ include(CocosConfigDefine)
3641

3742
# config libraries dependence
3843
include(CocosConfigDepend)
44+
45+
if(COCOS_COMMAND)
46+
get_filename_component(cocos2dx_console_dir ${COCOS_COMMAND} DIRECTORY)
47+
set(COCOS2DX_LUAJIT_ROOT ${cocos2dx_console_dir}/../plugins/plugin_luacompile/bin)
48+
message(STATUS "COCOS2DX_LUAJIT_ROOT:" ${COCOS2DX_LUAJIT_ROOT})
49+
if("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows")
50+
find_program(LUAJIT32_COMMAND NAMES luajit-win32 PATHS ${COCOS2DX_LUAJIT_ROOT}/32bit NO_SYSTEM_ENVIRONMENT_PATH)
51+
find_program(LUAJIT64_COMMAND NAMES luajit-win32 PATHS ${COCOS2DX_LUAJIT_ROOT}/64bit NO_SYSTEM_ENVIRONMENT_PATH)
52+
elseif("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Linux")
53+
find_program(LUAJIT32_COMMAND NAMES luajit-linux PATHS ${COCOS2DX_LUAJIT_ROOT}/32bit NO_SYSTEM_ENVIRONMENT_PATH)
54+
find_program(LUAJIT64_COMMAND NAMES luajit-linux PATHS ${COCOS2DX_LUAJIT_ROOT}/64bit NO_SYSTEM_ENVIRONMENT_PATH)
55+
endif()
56+
endif()
57+
58+
59+
if(WINDOWS OR LINUX)
60+
message(STATUS "LUAJIT32_COMMAND:" ${LUAJIT32_COMMAND})
61+
message(STATUS "LUAJIT64_COMMAND:" ${LUAJIT64_COMMAND})
62+
endif()

0 commit comments

Comments
 (0)