Game Development Reference
In-Depth Information
Table 12-2. GPT Source Files
Filename
Purpose
GPTActivity.java
Fulfills the requirement of an Activity class
GPTEditorGameObject.java
GameObject class with properties related to the Scene Editor
GPTSceneEditorView.java
Custom View for placing objects in a scene
GPTScriptEditorView.java
Custom View for editing scripts manually
GPTJNILib.java
Exposes native functions to other Java classes
GPTGameObject.java
GameObject class with properties related to the Scene Player
GPTScenePlayerView.java
Custom View for playing a scene
GPTMain.cpp
Implements the native functions declared in GPTJNILib.java
GPTScriptEngine.h
Declaration of the script engine's class and members
GPTScriptEngine.cpp
Implementation of the script engine's member functions
User Interface Implementation
Now that the required tools are installed, let's create a new Android project. First, open the Eclipse IDE if it's not
already running. The following dialogs may be different on other machines, but should still be fairly consistent. Click
the File menu, go to New and click Project. In the New Project dialog box, select the Android Application Project
wizard and click Next. Write down a project name, such as “GPT” or “Game Prototyping Tool.” Next, change the
package name to com.gametoolgems.gpt or something similar. Now, choose a build SDK and a minimum required
SDK. The code I've written requires at least API Level 10, but with a few changes, it can compile on a lower SDK
version. Select an SDK that is appropriate for the devices you want to target and click Next. Keep going until the wizard
asks for an activity name and choose an appropriate name, like “GPTActivity.” Keep going through the wizard until
you can click the Finish button. A new Android project will be created in your workspace folder.
GPTActivity
The main activity class doesn't have to do much. In its onCreate method, it will make instances of the three View
classes in the application and then bring the scene editor to the front. When handling the onBackPressed event, it
will simply pass it forward to the current View . To do this, it needs to keep track of the current View so it will publicly
expose a SetCurrentView method. Listing 12-1 represents the code for GPTActivity .
Listing 12-1. GPTActivity Class
public class GPTActivity extends Activity
{
private View mCurrentView = null;
public static GPTScriptEditorView scriptEditorView;
public static GPTSceneEditorView sceneEditorView;
public static GPTScenePlayerView scenePlayerView;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
 
Search WWH ::




Custom Search