Game Development Reference
In-Depth Information
while statement
while (expression)
{
// Statements here execute as long as expression evaluates // to true;
}
for statement
for (variable counter initialization;
expression;
variable counter increment/decrement)
{
// variable counter initialized when for loop is first
// executed
// Statements here execute as long as expression is true
// counter variable is updated
}
Java Classes
Java is an object-oriented language. What this means is that you can derive or extend existing
classes to form new customized classes of the existing classes. The derived class will have all the
functionality of the parent class, in addition to any new functions that you may want to add in.
The following class is a customized version of the parent class from which it derives, which is the
Activity class.
public class MainActivity extends Activity
{
// Body of class
}
Packages and Classes
Packages are a way in Java to group together classes and interfaces that are related in some way.
For example, a package can represent a game or other single application. The following is the
package designation for the “Hello Droid” Android project that I cover at the end of this chapter.
package com.robsexample.glhelloworld;
Accessing Classes in Packages
In order to access classes that are located in other packages, you have to bring them into view using
the “import” statement. For example, in order to use the GLSurfaceView class that is located inside
the android.opengl.GLSurfaceView package, you have to import it with the following statement:
import android.opengl.GLSurfaceView;
 
Search WWH ::




Custom Search