Skip to content

Commit

Permalink
添加编译说明,屏蔽警告,使用utf8
Browse files Browse the repository at this point in the history
HomeScene.cpp中为测试
  • Loading branch information
melonedo committed Jun 4, 2020
1 parent 9abba9e commit 48864df
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ proj.android

# Build files
win32-build
cocos2d
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ if(APPLE OR WINDOWS)
cocos_mark_multi_resources(common_res_files RES_TO "Resources" FOLDERS ${GAME_RES_FOLDER})
endif()

if(WINDOWS)
# use utf-8 encoding
add_compile_options(/wo4244 /wo4996 /utf-8)
# set startup project
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT APP_NAME)
# suppress warnings in cocos2d
target_compile_options(cocos2d PRIVATE /w)
endif()

# add cross-platforms source files and header files
list(APPEND GAME_SOURCE
Classes/AppDelegate.cpp
Expand Down
10 changes: 5 additions & 5 deletions Classes/HomeScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ HomeScene* HomeScene::create(callback_t on_start_pressed,
scene->addChild(title_label, 0, "title_label");

// 开始键
auto start_label =
Label::createWithTTF(ttfconfig, "Start", TextHAlignment::CENTER);
auto start_label = Label::createWithSystemFont(
"开始", "Microsoft YaHei", 60, Size::ZERO, TextHAlignment::CENTER);
assert(start_label);
start_label->setAnchorPoint(Vec2(0.5f, 0.5f));
start_label->setPosition(designResolutionSize.width / 2,
designResolutionSize.height * 0.6f);
scene->addChild(start_label, 0, "start_label");
scene->addChild(start_label, 0, "start_label");

// 设置键
auto settings_label =
Label::createWithTTF(ttfconfig, "Settings", TextHAlignment::CENTER);
auto settings_label = Label::createWithSystemFont(
"设置", "Microsoft YaHei", 60, Size::ZERO, TextHAlignment::CENTER);
assert(settings_label);
settings_label->setAnchorPoint(Vec2(0.5f, 0.5f));
settings_label->setPosition(designResolutionSize.width / 2,
Expand Down
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,22 @@
# fate-grand-rider
2020 oop assignment

## 编译
* 下载本项目repo:
```shell
git clone https://github.com/melonedo/fate-grand-rider.git
cd fate-grand-rider
```
* 下载cocos2d-x-4.0,把cocos2d-x-4.0的文件解压并放到`cocos2d`文件夹中(coco2d中应有`cmake`, `cocos`, `external`等文件夹);
* 进入`fate-grand-rider`后使用下列指令编译(需要vs2019和cmake):
```shell
mkdir win32-build
cd win32-build
cmake .. -G "Visual Studio 16 2019" -A win32
cmake --build . --config Release
cd ..
```
* 运行,程序位于`win32-build/bin/fate-grand-rider/Release`,可进入文件夹后手动打开`fate-grand-rider.exe`,也可继续在命令行中使用指令:
```shell
win32-build/bin/fate-grand-rider/Release/fate-grand-rider.exe
```

0 comments on commit 48864df

Please sign in to comment.