Skip to content

Commit 3e102fe

Browse files
committed
Updated engine and build system to 2.1.0, quick build by axmol build
1 parent 442f795 commit 3e102fe

Some content is hidden

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

51 files changed

+521
-159
lines changed

.axproj.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"engine_version": "axmol-1.0.0",
3-
"project_type": "cpp"
4-
}
2+
"engine_version": "2.1.0",
3+
"project_type": "cpp"
4+
}

CMakeLists.txt

Lines changed: 70 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#/****************************************************************************
22
# Copyright (c) 2013-2014 cocos2d-x.org
3-
# Copyright (c) 2021-2022 Bytedance Inc.
3+
# Copyright (c) 2019-present Axmol Engine contributors (see AUTHORS.md).
44
#
55
# https://axmolengine.github.io/
66
#
@@ -43,14 +43,13 @@ if(NOT DEFINED BUILD_ENGINE_DONE) # to test Tanks4 into root project
4343
set(_AX_ROOT "$ENV{AX_ROOT}")
4444

4545
if(NOT (_AX_ROOT STREQUAL ""))
46-
set(_AX_ROOT_PATH "${_AX_ROOT}")
47-
file(TO_CMAKE_PATH ${_AX_ROOT_PATH} _AX_ROOT_PATH) # string(REPLACE "\\" "/" _AX_ROOT_PATH ${_AX_ROOT_PATH})
46+
file(TO_CMAKE_PATH ${_AX_ROOT} _AX_ROOT)
4847
message(STATUS "Using system env var _AX_ROOT=${_AX_ROOT}")
4948
else()
50-
message(FATAL_ERROR "Please run setup.py add system env var 'AX_ROOT' to specific the engine root")
49+
message(FATAL_ERROR "Please run setup.ps1 add system env var 'AX_ROOT' to specific the engine root")
5150
endif()
5251

53-
set(CMAKE_MODULE_PATH ${_AX_ROOT_PATH}/cmake/Modules/)
52+
set(CMAKE_MODULE_PATH ${_AX_ROOT}/cmake/Modules/)
5453

5554
include(AXBuildSet)
5655

@@ -78,12 +77,12 @@ if(NOT DEFINED BUILD_ENGINE_DONE) # to test Tanks4 into root project
7877
endif()
7978

8079
set(_AX_USE_PREBUILT FALSE)
81-
if ((WIN32 OR LINUX) AND DEFINED AX_PREBUILT_DIR AND IS_DIRECTORY ${_AX_ROOT_PATH}/${AX_PREBUILT_DIR})
80+
if ((WIN32 OR LINUX) AND DEFINED AX_PREBUILT_DIR AND IS_DIRECTORY ${_AX_ROOT}/${AX_PREBUILT_DIR})
8281
set(_AX_USE_PREBUILT TRUE)
8382
endif()
8483

8584
if (NOT _AX_USE_PREBUILT)
86-
add_subdirectory(${_AX_ROOT_PATH}/core ${ENGINE_BINARY_PATH}/axmol/core)
85+
add_subdirectory(${_AX_ROOT}/core ${ENGINE_BINARY_PATH}/axmol/core)
8786
endif()
8887
endif()
8988

@@ -100,28 +99,28 @@ if (NOT DEFINED AX_PREBUILT_DIR)
10099
AX_USE_WEBP=0)
101100
endif()
102101

103-
# record sources, headers, Content...
104-
set(GAME_SOURCE)
105-
set(GAME_HEADER)
102+
# The common cross-platforms source files and header files
103+
file(GLOB_RECURSE GAME_HEADER
104+
Source/*.h Source/*.hpp
105+
)
106+
file(GLOB_RECURSE GAME_SOURCE
107+
Source/*.cpp Source/*.c
108+
)
109+
110+
set(GAME_INC_DIRS
111+
"${CMAKE_CURRENT_SOURCE_DIR}/Source"
112+
)
106113

107114
set(content_folder
108115
"${CMAKE_CURRENT_SOURCE_DIR}/Content"
109116
)
117+
110118
if(APPLE)
111-
ax_mark_multi_resources(common_content_files RES_TO "Resources" FOLDERS ${GAME_RES_FOLDER})
119+
ax_mark_multi_resources(common_content_files RES_TO "Resources" FOLDERS ${content_folder})
112120
elseif(WINDOWS)
113-
ax_mark_multi_resources(common_content_files RES_TO "Content" FOLDERS ${GAME_RES_FOLDER})
121+
ax_mark_multi_resources(common_content_files RES_TO "Content" FOLDERS ${content_folder})
114122
endif()
115123

116-
# add cross-platforms source files and header files
117-
file(GLOB_RECURSE GAME_SOURCE
118-
Source/*.cpp
119-
)
120-
121-
file(GLOB_RECURSE GAME_HEADER
122-
Source/*.h
123-
)
124-
125124
if(ANDROID)
126125
# the APP_NAME should match on AndroidManifest.xml
127126
list(APPEND GAME_SOURCE
@@ -131,16 +130,26 @@ elseif(LINUX)
131130
list(APPEND GAME_SOURCE
132131
proj.linux/main.cpp
133132
)
134-
elseif(WINDOWS)
135-
list(APPEND GAME_HEADER
136-
proj.win32/main.h
137-
proj.win32/resource.h
138-
)
133+
list(APPEND GAME_SOURCE ${common_content_files})
134+
elseif(WASM)
139135
list(APPEND GAME_SOURCE
140-
proj.win32/main.cpp
141-
proj.win32/game.rc
142-
${common_content_files}
136+
proj.wasm/main.cpp
143137
)
138+
list(APPEND GAME_SOURCE ${common_content_files})
139+
elseif(WINDOWS)
140+
if(NOT WINRT)
141+
list(APPEND GAME_HEADER
142+
proj.win32/main.h
143+
proj.win32/resource.h
144+
)
145+
list(APPEND GAME_SOURCE
146+
proj.win32/main.cpp
147+
proj.win32/game.rc
148+
)
149+
else()
150+
ax_setup_winrt_sources()
151+
endif()
152+
list(APPEND GAME_SOURCE ${common_content_files})
144153
elseif(APPLE)
145154
if(IOS)
146155
list(APPEND GAME_HEADER
@@ -150,13 +159,13 @@ elseif(APPLE)
150159

151160
if (TVOS)
152161
set(APP_UI_RES
153-
proj.ios_mac/ios/LaunchScreenBackground.png
162+
proj.ios_mac/ios/targets/tvos/LaunchScreenBackground.png
154163
proj.ios_mac/ios/targets/tvos/LaunchScreen.storyboard
155164
proj.ios_mac/ios/targets/tvos/Images.xcassets
156165
)
157166
else()
158167
set(APP_UI_RES
159-
proj.ios_mac/ios/LaunchScreenBackground.png
168+
proj.ios_mac/ios/targets/ios/LaunchScreenBackground.png
160169
proj.ios_mac/ios/targets/ios/LaunchScreen.storyboard
161170
proj.ios_mac/ios/targets/ios/Images.xcassets
162171
)
@@ -184,14 +193,14 @@ elseif(APPLE)
184193
endif()
185194

186195
# mark app complie info and libs info
187-
set(all_code_files
196+
set(APP_SOURCES
188197
${GAME_HEADER}
189198
${GAME_SOURCE}
190199
)
191200
if(NOT ANDROID)
192-
add_executable(${APP_NAME} ${all_code_files})
201+
add_executable(${APP_NAME} ${APP_SOURCES})
193202
else()
194-
add_library(${APP_NAME} SHARED ${all_code_files})
203+
add_library(${APP_NAME} SHARED ${APP_SOURCES})
195204
# whole archive for jni
196205
target_link_libraries(${APP_NAME} -Wl,--whole-archive cpp_android_spec -Wl,--no-whole-archive)
197206
config_android_shared_libs("org.axmol.lib" "${CMAKE_CURRENT_SOURCE_DIR}/proj.android/app/src")
@@ -201,17 +210,20 @@ if (NOT _AX_USE_PREBUILT)
201210
target_link_libraries(${APP_NAME} ${_AX_CORE_LIB})
202211
endif()
203212

204-
target_include_directories(${APP_NAME}
205-
PRIVATE Source
206-
PRIVATE ${_AX_ROOT_PATH}/core/audio
207-
)
213+
# The optional thirdparties(not dependent by engine)
214+
if (AX_WITH_YAML_CPP)
215+
list(APPEND GAME_INC_DIRS "${_AX_ROOT}/thirdparty/yaml-cpp/include")
216+
endif()
217+
218+
target_include_directories(${APP_NAME} PRIVATE ${GAME_INC_DIRS})
219+
208220

209-
# mark app resources
210-
setup_ax_app_config(${APP_NAME})
221+
# mark app resources, resource will be copy auto after mark
222+
ax_setup_app_config(${APP_NAME})
211223
if(APPLE)
212224
set_target_properties(${APP_NAME} PROPERTIES RESOURCE "${APP_UI_RES}")
213225
set_xcode_property(${APP_NAME} INSTALL_PATH "\$(LOCAL_APPS_DIR)")
214-
set_xcode_property(${APP_NAME} PRODUCT_BUNDLE_IDENTIFIER "org.axmol.hellocpp")
226+
set_xcode_property(${APP_NAME} PRODUCT_BUNDLE_IDENTIFIER "org.eugenyn.tanks4")
215227

216228
if(MACOSX)
217229
set_target_properties(${APP_NAME} PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/proj.ios_mac/mac/Info.plist")
@@ -221,37 +233,42 @@ if(APPLE)
221233
elseif(IOS)
222234
set_target_properties(${APP_NAME} PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/proj.ios_mac/ios/targets/ios/Info.plist")
223235
set_xcode_property(${APP_NAME} ASSETCATALOG_COMPILER_APPICON_NAME "AppIcon")
236+
set_xcode_property(${APP_NAME} TARGETED_DEVICE_FAMILY "1,2")
224237
endif()
225238

226239
# For code-signing, set the DEVELOPMENT_TEAM:
227240
#set_xcode_property(${APP_NAME} DEVELOPMENT_TEAM "GRLXXXX2K9")
228241
elseif(WINDOWS)
229242
if(NOT _AX_USE_PREBUILT)
230-
ax_copy_target_dll(${APP_NAME})
243+
ax_sync_target_dlls(${APP_NAME})
231244
endif()
232245
endif()
233246

234-
if (NOT APPLE)
247+
if ((NOT APPLE) AND (NOT WINRT))
235248
ax_get_resource_path(APP_RES_DIR ${APP_NAME})
236249
ax_sync_target_res(${APP_NAME} LINK_TO ${APP_RES_DIR} FOLDERS ${content_folder} SYM_LINK 1)
237250

238-
if((WINDOWS AND (NOT (CMAKE_GENERATOR STREQUAL "Ninja"))))
251+
if((WINDOWS AND (NOT (CMAKE_GENERATOR MATCHES "Ninja"))))
239252
set_property(TARGET ${APP_NAME} PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "${content_folder}")
240253
if(NOT DEFINED BUILD_ENGINE_DONE)
241254
set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT ${APP_NAME})
242255
endif()
243256
endif()
244-
endif()
245-
246-
# The optional thirdparties(not dependent by engine)
247-
if (AX_WITH_YAML_CPP)
248-
target_include_directories(${APP_NAME} PRIVATE ${_AX_ROOT_PATH}/thirdparty/yaml-cpp/include)
249-
target_link_libraries(${APP_NAME} yaml-cpp)
257+
elseif(WINRT)
258+
if(NOT DEFINED BUILD_ENGINE_DONE)
259+
set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT ${APP_NAME})
260+
endif()
250261
endif()
251262

252263
if (_AX_USE_PREBUILT) # support windows and linux
253264
use_ax_compile_define(${APP_NAME})
254265

255-
include(${_AX_ROOT_PATH}/cmake/Modules/AXLinkHelpers.cmake)
256-
ax_link_cxx_prebuilt(${APP_NAME} ${_AX_ROOT_PATH} ${AX_PREBUILT_DIR})
257-
endif()
266+
include(AXLinkHelpers)
267+
ax_link_cxx_prebuilt(${APP_NAME} ${_AX_ROOT} ${AX_PREBUILT_DIR})
268+
endif()
269+
270+
if (NOT DEFINED BUILD_ENGINE_DONE)
271+
ax_uwp_set_all_targets_deploy_min_version()
272+
endif()
273+
274+
ax_setup_app_props(${APP_NAME})

Content/res/.gitkeep

Whitespace-only changes.

README.md

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,26 +36,37 @@ Also the game is available on Itch.io: https://eugenyn.itch.io/tanks-kombat
3636

3737
## Build from source
3838

39-
#### Prerequisites
39+
### Prerequisites
4040

4141
1. Download [Axmol](https://github.com/axmolengine/axmol) game engine.
42-
2. Config ```axmol```, run ```python setup.py``` from axmol root directory.
42+
2. Install [PowerShell](https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell), powershell-7 is recommended, it's support Windows, macOS, Linux
43+
3. Config ```axmol```, run ```pwsh setup.ps1``` from axmol root directory.
44+
4. Ensure C/C++ compiler toolset installed on your machine.
4345

44-
#### Windows
46+
### Quick build by `axmol build` for all target platforms [`Recommended`]
4547

46-
1. Install Visual Studio 2019/2022 (for toolchain)
47-
2. Install [CMake](https://cmake.org/) 3.14+
48+
Using a powershell console window, the `axmol build` command will auto setup general depended toolsets, so you can simply build project for all platform targets, i.e.
49+
50+
- win32: `axmol build -p win32`
51+
- android: `axmol build -p android -a arm64` can runs on Windows, Linux, macOS and script will auto setup android sdk
52+
53+
See [DevSetup](https://github.com/axmolengine/axmol/blob/dev/docs/DevSetup.md) for additional options.
54+
55+
### Manually build with cmake
56+
57+
#### Windows (Visual Studio)
58+
59+
1. Install Visual Studio 2022 (for toolchain)
60+
2. Install [CMake](https://cmake.org/) 3.28.1+
4861
3. Use CMake to build project files:
4962
* for 32 bit Visual Studio 2022: ```cmake -S . -B build -G "Visual Studio 17 2022" -A Win32```
5063
* for 64 bit Visual Studio 2022: ```cmake -S . -B build -G "Visual Studio 17 2022" -A x64```
51-
4. Build and run project.
52-
53-
Also you can use built-in CMake projects support in your IDE (use Visual Studio as toolchain)
64+
4. Use Visual Studio to open the newly created solution file. Build and run project.
5465

55-
#### Android
66+
#### Android (Android Studio)
5667

57-
1. Install Android Studio
58-
2. Install SDK Build-Tools, NDK r23c+, CMake 3.10+ from Android Studio ```SDK Manager```
68+
1. Install Android Studio 2023.1.1+
69+
2. Install SDK Build-Tools 34.0.0, NDK r23c+, CMake, from Android Studio ```SDK Manager```, use Gradle Plugin (AGP) 8.2.1
5970
3. Open ```proj.android``` in Android Studio, wait for ```Gradle sync``` finish.
6071
4. Build and run project.
6172

@@ -68,7 +79,7 @@ Also you can use built-in CMake projects support in your IDE (use Visual Studio
6879

6980
## Third-party code and libraries
7081

71-
* [Axmol Game Engine](https://github.com/axmolengine/axmol) fork of [Cocos2d-x-4.0](https://github.com/cocos2d/cocos2d-x)
82+
* [Axmol Game Engine](https://github.com/axmolengine/axmol)
7283
* [SneakyInput-Cocos2dx-2.0.x](https://github.com/cpinan/SneakyInput-Cocos2dx-2.0.x)
7384
* [Random Cave Using Cellular Automata](http://gamedevelopment.tutsplus.com/tutorials/generate-random-cave-levels-using-cellular-automata--gamedev-9664)
7485
* [A* Pathfinding with Cocos2D](http://www.raywenderlich.com/4970/how-to-implement-a-pathfinding-with-cocos2d-tutorial) (Objective-C)

Source/AppDelegate.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#ifndef _APP_DELEGATE_H_
22
#define _APP_DELEGATE_H_
33

4-
#include "cocos2d.h"
4+
#include "axmol.h"
55

6-
class AppDelegate : private cocos2d::Application
6+
class AppDelegate : private ax::Application
77
{
88
public:
99
AppDelegate();

Source/Components/AI.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include "Objects\Bonus.h"
55
#include "Objects\GameObject.h"
66
#include "Scenes\GameplayScene.h"
7-
#include "base/CCEventListenerCustom.h"
7+
#include "base/EventListenerCustom.h"
88

99
USING_NS_CC;
1010

Source/Engine.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#include "Engine.h"
22
#include "Scenes\BaseScene.h"
33
#include "Scenes\MainMenuScene.h"
4-
#include "2d/CCFontAtlasCache.h"
4+
#include "2d/FontAtlasCache.h"
55
#include "audio/AudioEngine.h"
66

7-
USING_NS_CC;
7+
USING_NS_AX;
88

99
GameMode GameMode::createFromDict(const ValueMap& dict)
1010
{
@@ -62,18 +62,18 @@ void Engine::launchGame()
6262
loadSettings();
6363

6464
auto director = Director::getInstance();
65-
auto glview = director->getOpenGLView();
65+
auto glview = director->getGLView();
6666

6767
if (!glview) {
68-
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) || (CC_TARGET_PLATFORM == CC_PLATFORM_LINUX)
68+
#if (AX_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (AX_TARGET_PLATFORM == CC_PLATFORM_MAC) || (AX_TARGET_PLATFORM == CC_PLATFORM_LINUX)
6969
if (Settings.fullscreen)
7070
glview = GLViewImpl::createWithFullScreen(GAME_TITLE);
7171
else
7272
glview = GLViewImpl::createWithRect(GAME_TITLE, Rect(0, 0, Settings.windowsSize.width, Settings.windowsSize.height));
7373
#else
7474
glview = GLViewImpl::create(GAME_TITLE);
7575
#endif
76-
director->setOpenGLView(glview);
76+
director->setGLView(glview);
7777
}
7878

7979
director->setDisplayStats(DISPLAY_STATS);

Source/Scenes/AboutScene.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ bool AboutScene::init()
4040
"zironid_n, M-Tee\n"
4141
"Kenney Vleugels\n\n"
4242
"3d party code:\n\n"
43-
"Cocos2d-x 3.9, SneakyInput";
43+
"Axmol 2.1, SneakyInput";
4444

4545
const char* aboutYellow =
4646
"Programming and game design:\n\n"
@@ -87,7 +87,7 @@ void AboutScene::showDebugInfo()
8787

8888
Size visibleSize = Director::getInstance()->getVisibleSize();
8989
Point origin = Director::getInstance()->getVisibleOrigin();
90-
auto glview = Director::getInstance()->getOpenGLView();
90+
auto glview = Director::getInstance()->getGLView();
9191

9292
float dpiScale = (float)Device::getDPI() / 86.0f;
9393
float resolutionScale = 1.0f / glview->getScaleX();

Source/Scenes/BaseScene.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ void BaseScene::addJoystick()
201201
{
202202
Size visibleSize = Director::getInstance()->getVisibleSize();
203203
Point origin = Director::getInstance()->getVisibleOrigin();
204-
auto glview = Director::getInstance()->getOpenGLView();
204+
auto glview = Director::getInstance()->getGLView();
205205

206206
float dpiScale = (float)Device::getDPI() / 86.0f;
207207
float resolutionScale = 1.0f / glview->getScaleX();

build.bat

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@echo off
2+
axmol build -p win32

0 commit comments

Comments
 (0)