public class GameGrid
extends android.app.Activity
implements android.media.MediaPlayer.OnCompletionListener
Modifier and Type | Field and Description |
---|---|
java.lang.String |
turtleImage |
DEFAULT_KEYS_DIALER, DEFAULT_KEYS_DISABLE, DEFAULT_KEYS_SEARCH_GLOBAL, DEFAULT_KEYS_SEARCH_LOCAL, DEFAULT_KEYS_SHORTCUT, RESULT_CANCELED, RESULT_FIRST_USER, RESULT_OK
ACCESSIBILITY_SERVICE, ACCOUNT_SERVICE, ACTIVITY_SERVICE, ALARM_SERVICE, AUDIO_SERVICE, BIND_AUTO_CREATE, BIND_DEBUG_UNBIND, BIND_NOT_FOREGROUND, CLIPBOARD_SERVICE, CONNECTIVITY_SERVICE, CONTEXT_IGNORE_SECURITY, CONTEXT_INCLUDE_CODE, CONTEXT_RESTRICTED, DEVICE_POLICY_SERVICE, DROPBOX_SERVICE, INPUT_METHOD_SERVICE, KEYGUARD_SERVICE, LAYOUT_INFLATER_SERVICE, LOCATION_SERVICE, MODE_APPEND, MODE_PRIVATE, MODE_WORLD_READABLE, MODE_WORLD_WRITEABLE, NOTIFICATION_SERVICE, POWER_SERVICE, SEARCH_SERVICE, SENSOR_SERVICE, TELEPHONY_SERVICE, UI_MODE_SERVICE, VIBRATOR_SERVICE, WALLPAPER_SERVICE, WIFI_SERVICE, WINDOW_SERVICE
Modifier and Type | Method and Description |
---|---|
void |
act()
Empty method called in every simulation cycle after all actor act() calls.
|
GGStatusBar |
addStatusBar(int barHeight)
Adds a status bar at the bottom of the game grid window where a single
line of text can be displayed.
|
GGStatusBar |
addStatusBar(int ulx,
int uly,
int barWidth,
int barHeight)
Adds a status bar at a user defined position of the screen.
|
void |
onCompletion(android.media.MediaPlayer mp)
Notification method called when the playback of a media file terminates.
|
void |
onConfigurationChanged(android.content.res.Configuration newConfig)
Called by the system when the configuration is modified, e.g. when
the device orientation changes.
|
boolean |
onKeyDown(int keyCode,
android.view.KeyEvent event)
Notification method when a key is pressed.
|
boolean |
onKeyLongPress(int keyCode,
android.view.KeyEvent event)
Notification method when a key is long pressed.
|
boolean |
onKeyUp(int keyCode,
android.view.KeyEvent event)
Notification method when a key is released.
|
void |
playgroundClicked(double x,
double y)
Event notification when the playground is clicked.
|
void |
playgroundDragged(double x,
double y)
Event notification when the playground is dragged.
|
void |
playgroundDragged(double x,
double y,
int pointerId)
Event notification when the playground is dragged in a multi-touch
event.
|
void |
playgroundFlung(double xStart,
double yStart,
double xEnd,
double yEnd,
double v,
double dir)
Event notification when a fling event is detected.
|
void |
playgroundLongPressed(double x,
double y)
Event notification when the playground is long pressed.
|
void |
playgroundPointerPressed(double x,
double y,
int pointerId)
Event notification when the playground is pressed (by the second,
third, ... finger) in a multi-touch event.
|
void |
playgroundPointerReleased(double x,
double y,
int pointerId)
Event notification when the playground is released (by the
second, third, ... finger) in a multi-touch event.
|
void |
playgroundPressed(double x,
double y)
Event notification when the playground is pressed.
|
void |
playgroundPressed(double x,
double y,
int pointerId)
Event notification when the playground is pressed (by the first
in a multi-touch event.
|
void |
playgroundReleased(double x,
double y)
Event notification when the playground is released.
|
void |
playgroundReleased(double x,
double y,
int pointerId)
Event notification when the playground is released by the
last finger in a multi-touch event.
|
void |
playSound(java.lang.String soundResource)
Same as playSound(String soundResource, boolean blocking) with
blocking = true.
|
android.media.MediaPlayer |
playSound(java.lang.String soundResource,
boolean blocking)
Plays the given sound resource.
|
void |
refresh()
Repaints the graphics to show any changes in the offscreen buffer.
|
void |
setDragEnabled(boolean enable)
Enable/disable drag event callbacks
(to be active, touch must be enabled too)
Because drag events may be triggered in rapid sequence,
drag events are disabled by default.
|
void |
setMultiDragEnabled(boolean enable)
Enable/disable multi-touch drag event callbacks.
|
void |
setMultiTouchEnabled(boolean enable)
Enable/disable all multi-touch event callbacks.
|
void |
setTouchEnabled(boolean enable)
Enable/disable touch event callbacks (also fling events).
|
void |
turtleClicked(Turtle turtle,
double x,
double y)
Event notification when a turtle is clicked.
|
void |
turtleDragged(Turtle turtle,
double x,
double y)
Event notification when a turtle is dragged.
|
void |
turtleLongPressed(Turtle turtle,
double x,
double y)
Event notification when a turtle is long pressed.
|
void |
turtlePressed(Turtle turtle,
double x,
double y)
Event notification when a turtle is pressed.
|
void |
turtleReleased(Turtle turtle,
double x,
double y)
Event notification when a turtle is released.
|
addContentView, closeContextMenu, closeOptionsMenu, createPendingResult, dismissDialog, dispatchKeyEvent, dispatchPopulateAccessibilityEvent, dispatchTouchEvent, dispatchTrackballEvent, findViewById, finish, finishActivity, finishActivityFromChild, finishFromChild, getApplication, getCallingActivity, getCallingPackage, getChangingConfigurations, getComponentName, getCurrentFocus, getInstanceCount, getIntent, getLastNonConfigurationInstance, getLayoutInflater, getLocalClassName, getMenuInflater, getParent, getPreferences, getRequestedOrientation, getSystemService, getTaskId, getTitle, getTitleColor, getVolumeControlStream, getWallpaperDesiredMinimumHeight, getWallpaperDesiredMinimumWidth, getWindow, getWindowManager, hasWindowFocus, isChild, isFinishing, isTaskRoot, managedQuery, moveTaskToBack, onAttachedToWindow, onBackPressed, onContentChanged, onContextItemSelected, onContextMenuClosed, onCreateContextMenu, onCreateDescription, onCreateOptionsMenu, onCreatePanelMenu, onCreatePanelView, onCreateThumbnail, onCreateView, onDetachedFromWindow, onKeyMultiple, onLowMemory, onMenuItemSelected, onMenuOpened, onOptionsItemSelected, onOptionsMenuClosed, onPanelClosed, onPrepareOptionsMenu, onPreparePanel, onRetainNonConfigurationInstance, onSearchRequested, onTouchEvent, onTrackballEvent, onUserInteraction, onWindowAttributesChanged, onWindowFocusChanged, openContextMenu, openOptionsMenu, overridePendingTransition, registerForContextMenu, removeDialog, requestWindowFeature, runOnUiThread, setContentView, setContentView, setContentView, setDefaultKeyMode, setFeatureDrawable, setFeatureDrawableAlpha, setFeatureDrawableResource, setFeatureDrawableUri, setIntent, setPersistent, setProgress, setProgressBarIndeterminate, setProgressBarIndeterminateVisibility, setProgressBarVisibility, setRequestedOrientation, setResult, setResult, setSecondaryProgress, setTitle, setTitle, setTitleColor, setVisible, setVolumeControlStream, showDialog, showDialog, startActivity, startActivityForResult, startActivityFromChild, startActivityIfNeeded, startIntentSender, startIntentSenderForResult, startIntentSenderFromChild, startManagingCursor, startNextMatchingActivity, startSearch, stopManagingCursor, takeKeyEvents, triggerSearch, unregisterForContextMenu
bindService, checkCallingOrSelfPermission, checkCallingOrSelfUriPermission, checkCallingPermission, checkCallingUriPermission, checkPermission, checkUriPermission, checkUriPermission, clearWallpaper, createPackageContext, databaseList, deleteDatabase, deleteFile, enforceCallingOrSelfPermission, enforceCallingOrSelfUriPermission, enforceCallingPermission, enforceCallingUriPermission, enforcePermission, enforceUriPermission, enforceUriPermission, fileList, getApplicationContext, getApplicationInfo, getAssets, getBaseContext, getCacheDir, getClassLoader, getContentResolver, getDatabasePath, getDir, getExternalCacheDir, getExternalFilesDir, getFilesDir, getFileStreamPath, getMainLooper, getPackageCodePath, getPackageManager, getPackageName, getPackageResourcePath, getResources, getSharedPreferences, getWallpaper, grantUriPermission, isRestricted, openFileInput, openFileOutput, openOrCreateDatabase, peekWallpaper, registerReceiver, registerReceiver, removeStickyBroadcast, revokeUriPermission, sendBroadcast, sendBroadcast, sendOrderedBroadcast, sendOrderedBroadcast, sendStickyBroadcast, sendStickyOrderedBroadcast, setWallpaper, setWallpaper, startInstrumentation, startService, stopService, unbindService, unregisterReceiver
public void refresh()
public void onConfigurationChanged(android.content.res.Configuration newConfig)
onConfigurationChanged
in interface android.content.ComponentCallbacks
onConfigurationChanged
in class android.app.Activity
newConfig
- a reference to the new configuration instancepublic void act()
public boolean onKeyDown(int keyCode, android.view.KeyEvent event)
onKeyDown
in interface android.view.KeyEvent.Callback
onKeyDown
in class android.app.Activity
keyCode
- the code of the keyevent
- the type of eventpublic boolean onKeyUp(int keyCode, android.view.KeyEvent event)
onKeyUp
in interface android.view.KeyEvent.Callback
onKeyUp
in class android.app.Activity
keyCode
- the code of the keyevent
- the type of eventpublic boolean onKeyLongPress(int keyCode, android.view.KeyEvent event)
onKeyLongPress
in interface android.view.KeyEvent.Callback
onKeyLongPress
in class android.app.Activity
keyCode
- the code of the keyevent
- the type of eventpublic void setTouchEnabled(boolean enable)
enable
- if true, the registered callbacks are enabled; otherwise disabledpublic void setDragEnabled(boolean enable)
enable
- if true, the registered callbacks are enabled; otherwise disabledpublic void setMultiDragEnabled(boolean enable)
enable
- if true, the registered callbacks are enabled; otherwise disabledpublic void setMultiTouchEnabled(boolean enable)
enable
- if true, the registered callbacks are enabled; otherwise disabledpublic android.media.MediaPlayer playSound(java.lang.String soundResource, boolean blocking)
soundResource
- the path name of the audio file
(must have one of the supported audio format). If no file name extension is used,
the resource file is searched in the 'raw' resource folder. If an extension
is given, the resource file is searched in the given relative path on the
sdcard (the prefix '/sdcard'/ is added by the system)blocking
- if true, blocks until sound has finished; otherwise
returns immediatelypublic void playSound(java.lang.String soundResource)
soundResource
- the path name of the audio file
(must have one of the supported audio format). If no file name extension is used,
the resource file is searched in the 'raw' resource folder. If an extension
is given, the resource file is searched in the given relative path on the
sdcard (the prefix '/sdcard'/ is added by the system)public void onCompletion(android.media.MediaPlayer mp)
onCompletion
in interface android.media.MediaPlayer.OnCompletionListener
mp
- the MediaPlayer that terminiatespublic GGStatusBar addStatusBar(int ulx, int uly, int barWidth, int barHeight)
ulx
- the pixel x-coordinate of the upper left vertexuly
- the pixel y-coordinate of the upper left vertexbarHeight
- the height of the status bar in pixel units
(the number of pixels is barHeight + 1).barWidth
- the width of the status bar in pixel units
(the number of pixels is barWidth + 1).public GGStatusBar addStatusBar(int barHeight)
barHeight
- the height of the status bar in pixel units
(the number of pixels is barHeight + 1).public void playgroundPressed(double x, double y)
x
- the x coordinate of the touch event (turtle coordinate system)y
- the y coordinate of the touch event (turtle coordinate system)public void playgroundPressed(double x, double y, int pointerId)
x
- the x coordinate of the touch event (turtle coordinate system)y
- the y coordinate of the touch event (turtle coordinate system)pointerId
- the pointer ID of the touch event (always 0)public void playgroundPointerPressed(double x, double y, int pointerId)
x
- the x coordinate of the touch event (turtle coordinate system)y
- the y coordinate of the touch event (turtle coordinate system)pointerId
- the pointer ID of the touch eventpublic void playgroundReleased(double x, double y)
x
- the x coordinate of the touch event (turtle coordinate system)y
- the y coordinate of the touch event (turtle coordinate system)public void playgroundReleased(double x, double y, int pointerId)
x
- the x coordinate of the touch event (turtle coordinate system)y
- the y coordinate of the touch event (turtle coordinate system)pointerId
- the pointer ID of the touch eventpublic void playgroundPointerReleased(double x, double y, int pointerId)
x
- the x coordinate of the touch event (turtle coordinate system)y
- the y coordinate of the touch event (turtle coordinate system)pointerId
- the pointer ID of the touch eventpublic void playgroundLongPressed(double x, double y)
x
- the x coordinate of the touch event (turtle coordinate system)y
- the y coordinate of the touch event (turtle coordinate system)public void playgroundClicked(double x, double y)
x
- the x coordinate of the touch event (turtle coordinate system)y
- the y coordinate of the touch event (turtle coordinate system)public void playgroundDragged(double x, double y)
x
- the x coordinate of the touch event (turtle coordinate system)y
- the y coordinate of the touch event (turtle coordinate system)public void playgroundDragged(double x, double y, int pointerId)
x
- the x coordinate of the touch event (turtle coordinate system)y
- the y coordinate of the touch event (turtle coordinate system)pointerId
- the pointer ID of the touch eventpublic void playgroundFlung(double xStart, double yStart, double xEnd, double yEnd, double v, double dir)
xStart
- the x coordinate of the finger touch location (turtle coordinate system)yStart
- the y coordinate of the finger touch location (turtle coordinate system)xEnd
- the x coordinate of the finger release location (turtle coordinate system)yEnd
- the y coordinate of the finger release location (turtle coordinate system)v
- the speed of the fling (in turtle coordinates per seconds)dir
- the direction of the fling (in degrees, 0 to north, clockwise)public void turtleClicked(Turtle turtle, double x, double y)
turtle
- the reference of the touched turtlex
- the x coordinate of the touch event (turtle coordinate system)y
- the y coordinate of the touch event (turtlec oordinate system)public void turtleDragged(Turtle turtle, double x, double y)
turtle
- the reference of the touched turtlex
- the x coordinate of the touch event (turtle coordinate system)y
- the y coordinate of the touch event (turtle coordinate system)public void turtlePressed(Turtle turtle, double x, double y)
turtle
- the reference of the touched turtlex
- the x coordinate of the touch event (turtle coordinate system)y
- the y coordinate of the touch event (turtle coordinate system)public void turtleReleased(Turtle turtle, double x, double y)
turtle
- the reference of the touched turtlex
- the x coordinate of the touch event (turtle coordinate system)y
- the y coordinate of the touch event (turtle coordinate system)public void turtleLongPressed(Turtle turtle, double x, double y)
turtle
- the reference of the touched turtlex
- the x coordinate of the touch event (turtle coordinate system)y
- the y coordinate of the touch event (turtle coordinate system)