【GamePlay3D】开发指南——部分翻译

来源:互联网 发布:杜夫.龙格尔 知乎 编辑:程序博客网 时间:2024/04/29 15:11

【说明:按照英文版的翻译过来的,水平有限,难免有很多翻译欠妥的地方,望谅解。突然发现里面都是没什么用的废话,就不继续翻译了。以后根据自己的学习情况,直接上笔记。实用又快速入门,有问题可以直接查阅官方文档。——断点的童话】

概述

GamePlay框架是一个开源、跨平台的游戏框架。他是为了让我们更简单的学习使用原生态的C++开发3D移动和桌面游戏。在这个开发指南中,我们包括了教会你在框架中从上层到底层的使用GamePlay的库、工具和所有主要的API方法。这个指南介绍了一套你可以开发游戏的C++类。

设计目标和注意事项

在创造GamePlay框架的时候,我们的目标不只是把重心放在创造一个高性能的原生C++游戏框架,而且给他塑造一种干净、简单、优雅的风格。本框架使用最小的跨平台外部依赖,并尝试使用最简单抽象的方法设计类。这种方法可以让你学习库中的类和扩展本框架来构建你自己的游戏引擎和工具。本框架对于学习怎么写3D跨平台移动和桌面游戏是一个很好的助跑器,让你花费更多的时间设计你的游戏。

为什么另写一个游戏引擎?

我们实际上希望GamePlay被认为是一个游戏框架。然而,实际上,他任然只是游戏引擎的核心组件。下面还有开发GamePlay框架的几个原因:

首先,大多数先进的3D游戏引擎都是封闭源代码的,虽然有的时候是免费或者便宜的。此外,他们通常有许可费。GamePlay框架Apache 2.0许可下是一个开源免费的自由软件。我们想要更多的人们知道跨平台是可实现的,并且为为人们进一步开发游戏打下坚实的基础。

其次,一个游戏引擎不只是渲染。不可否认,渲染占很大一部分,但是游戏引擎同样重要的有很多其他方面,比如:音频、物理、动画、UI形式、粒子发射器、脚本和数学。由于学习过程中机会的差异性,在网络上搜索并找到把这些东西合适的在游戏引擎或者游戏中使用,可能会把你的精力分散在很多地方。希望这个框架将这些一起为你带来。

最后,移动游戏很热门。GamePlay框架将会有很多重点在游戏和移动设备上。现在,移动游戏是游戏产业中增长最快的部门。此外,我们任然在工具和游戏上都提供对桌面平台的支持。然而,我们认为更多的重点应该放在移动游戏和学习怎样写出能够简单面向跨平台移动部门的游戏上。

编译框架

为了编译GamePlay库、工具和例子,还有开发你自己的游戏,你必须在不同平台下安装和使用下表中对应的开发工具。下表是对每一个特定的操作系统作为目标平台所支持的开发环境。

Desktop OS

Tool 

Development environment

Microsoft Windows 7

Visual Studio 2010

Windows 7

Apple Mac OS X

Xcode 4.3.2

Mac OS X

 

Mobile OS

Tool 

Development environment

BlackBerry PlayBook OS 2.0

BlackBerry Native SDK 2.0

Windows 7, Mac OS X

Android 2.3

Android NDK 7

Windows 7, Mac OS X

iOS 5.1

Xcode 4.3.2

Mac OS X

项目资料库

项目库中包括以下显着的文件夹和文件:

Folder/Files

Description

/bin

预编译二进制工具

/external-deps 

外部依赖函数库

/gameplay 

GamePlay

/gameplay-api 

Doxygen API 参考

/gameplay-docs 

文档指南和教程

/gameplay-encoder 

游戏的资产/内容编码工具

/gameplay-luagen

Lua脚本捆绑生成工具

/gameplay-template

游戏样本模板项目文件

/gameplay-samples

游戏例子

gameplay.xcworkspace

Xcode 工程

gameplay.sln

Microsoft Visual Studio 解决方案

gameplay-newproject.bat/.sh

新的跨平台项目脚本

开始桌面系统

最快的使用GamePlay框架和工具的方法是是在一个桌面环境中开始简单的工作。你必须在Windows 7上使用Microsoft Visual Studio 2010 ExpressProfessional版本,或者在Mac OS X上使用Xcode 4.3.2。接下来,只要打开Microsoft Visual Studio 解决方案或者Xcode 工程,然后编译运行项目。这些解决方案/工程被设置成默认编译所有所需要的项目,并且运行你所选择激活的例子程序。

瞧,你现在有几个简单的和交互的例子运行在你的桌面环境中。你可以探索他们,然后变得更加熟悉。

游戏范例

GamePlay文档文件夹中包含额外的范例教程文档。这些都是为了让你了解跟多的细节,来使用框架进行设计和开发游戏。他们都有一个好的起点,但是刻意的保留不完整。这提供了一个改变范例的机会,完善他们,让他们在交互和玩乐中带来更多乐趣。他提供了一个好的构建模块,都是你探索框架中不同特征的基础。你可以在自己的游戏中利用范例中的游戏片段来加速开发周期。

API参考

我们坚信在构建一个直观的API集上是直接了当并尽可能一致的。然而,框架中所有的类都已经使用Doxygen格式文档化。所有类将会在每一个版本中被反复更新或者改进。这将帮组你学习什么类或者哪些方法能被使用和按照推荐的方法使用他们。

你应该考虑从GamePlayAPI文件夹中预生成的HTMLDoxygen API文档里面阅读最新版本的API参考手册。这会让你更深入的理解C++ GamePlay框架。

开始移动设备

现在由你决定在哪一个桌面环境中运行,我们建议你认真思考,然后开始移动开发。现如今的移动游戏商店里面,跨平台的开发确实是一个现实。对面向广大设备受众,使用GamePlay框架是简单和容易的。开始下载支持的各种操作系统之一的原生开发套件,或者全部。

移动设置说明

下面列出的是关于GamePlay对支持的移动设备和开发环境基本的下载和安装安装说明。

BlackBerry Native SDK 2.0/10 Beta (PlayBook tablets and BlackBerry 10 devices)


1 Download and install the BlackBerry Native SDK 2.0 (for PlayBook) or BlackBerry 10 Beta (for BlackBerry 10 devices).

2 Run the QNX Momentics IDE (Eclipse CDT based) and click 
File > Import > Import Existing Projects.

3 Import all the gameplay projects by selecting the repository project folder. 

4 Set the active configuration to one of the Device-XXX or Simulator-XXX profiles.

5 Build and run any of the game samples.

Apple Xcode 4.3.2 (iPad tablets and iPhone devices)

Download and install Apple Xcode 4.

7 Open the gameplay.xc workspace.

8 Change the active configuration to iOS Device, iPhone Simulator, or iPad Simulator.

9 Build and run any of the game samples.

Android NDK 7 (Android tablets and devices)

10 Downloadand install Android NDK 7, Android SDK, Apache Ant, and GNU Make for Cygwin. 

1 Setup the Android SDK.

1 Make sure <android-sdk-path>/tools and <android-sdk-path>/platform-tools are added to PATH.

1 Setup the Android NDK and follow these instructions.

1 Make sure <android-ndk-path> is added to PATH.

1 Install Apache Ant.

1 Make sure <ant-path>/bin is added the PATH.

1 Install Cygwin and select and add the package make: The GNU version of the 'make' utility during installation. 

1 Rename awk.exe to something else (awk_.exe for example) in <android-ndk-path>/prebuilt/windows/bin. This is to prevent the Android build system from being confused by the cygwin's awk. 

1 Build the gameplay library using following steps:  Open the Cygwin terminal. 

1 Change to the <gameplay-root>/gameplay/android folder. 

1 Run the following command to generate the needed files to build the project:> android.bat update project -t 1 -p . -s

1 Run the following command to build the gameplay library:

> ndk-build

1 Build a sample game(s) with following steps:  Open the Cygwin terminal. 

1 Change to the:

<gameplay-root/gameplay-samples/sampleXX-XXXXX>/android folder.

2 Run the following command to generate the needed files to build the project:> android.bat update project -t 1 -p . -s

3 Run the following command to build the gameplay sample:> ndk-build 

Android NDK permissions errors:

If you see an error like "./obj/local/armeabi/libpng.a: No such file: Permission denied", make sure that the "*.a" files have read permission by running:

> chmod +r obj/local/armeabi/*.a

11 Connect the device and run the following command in the Cygwin terminal to deploy the game:> ant debug install

Note: If "ant debug install" does not work, ensure your device is being detected properly by running "adb devices". If no devices are reported, try downloading the correct USB drivers from you phone manufacturer's website. (OEM Drivers)

Linux (Ubuntu)

12 sudo apt-get install build-essential gcc cmake libglu1-mesa-dev libogg-dev libopenal-dev

13 cd build

14 cmake ..

15 make

移动平台的考虑

确保你能先在物理设备上测试。根据不同类型的游戏和设计理念,你会想要性能类型的一些方法,你会得到你努力想要得到的游戏计划和原型。要小心,不要依赖桌面和移动模拟器作为性能和移动设备能力的指标。