Game Development Reference
In-Depth Information
Then, you can use the class definition without the full package name, such as
private GLSurfaceView m_GLView;
Refer to the main Android developer's web site to find out more information about Android's built-in
classes, as well as the exact import you need to specify to use these classes in your own programs.
Java Interfaces
The purpose of a Java interface is to provide a standard way for programmers to implement the
actual functions in an interface in code in a derived class. An interface does not contain any actual
code, only the function definitions. The function bodies with the actual code must be defined by
other classes that implement that interface. A good example of a class that implements an interface
is the render class that is used for rendering graphics in OpenGL on the Android platform.
public class MyGLRenderer implements GLSurfaceView.Renderer
{
// This class implements the functions defined in the
// GLSurfaceView.Renderer interface
// Custom code
private PointLight m_Light;
public PointLight m_PublicLight;
void SetupLights()
{
// Function Body
}
// Other code that implements the interface
}
Accessing Class Variables and Functions
You can access a class's variables and functions through the “ . ” operator, just as in C++. See the
following examples:
MyGLRenderer m_Renderer;
m_Renderer.m_PublicLight = null; // ok
m_Renderer.SetupLights(); // ok
m_Renderer.m_Light = null; // error private member
Java Functions
The general format for Java functions is the same as in other languages, such as C/C++. The
function heading starts with optional modifiers, such as private, public, or static. Next is a return
value that can be void, if there is no return value or a basic data type or class. This is followed by the
function name and then the parameter list.
 
Search WWH ::




Custom Search