public class GameGrid extends android.app.Activity implements GGActListener, android.media.MediaPlayer.OnCompletionListener
Modifier and Type | Class and Description |
---|---|
static class |
GameGrid.CellZoom
Class to define a zoom factor for automatic zooming when images
are loaded in grid based apps.
|
class |
GameGrid.SysInfo
Class to retrieve system information.
|
static class |
GameGrid.WindowZoom
Class to define a zoom factor for automatic zooming when images
are loaded in pixel based apps.
|
Modifier and Type | Field and Description |
---|---|
static int |
BLACK
Short for Color.BLACK.
|
static int |
BLUE
Short for Color.BLUE.
|
static int |
CYAN
Short for Color.CYAN.
|
static int |
DKGRAY
Short for Color.DKGRAY.
|
static int |
GRAY
Short for Color.GRAY.
|
static int |
GREEN
Short for Color.GREEN.
|
static GGNavigationListener.ScreenOrientation |
KILLPROCESS
Constant for setScreenOrientation().
|
static GGNavigationListener.ScreenOrientation |
LANDSCAPE
Constant for setScreenOrientation().
|
static int |
LTGRAY
Short for Color.LTGRAY.
|
static int |
MAGENTA
Short for Color.MAGENTY.
|
static java.lang.Object |
monitor |
static GameGrid |
myGameGrid
Public access to the GameGrid instance.
|
static GGNavigationListener.ScreenOrientation |
PORTRAIT
Constant for setScreenOrientation().
|
static int |
RED
Short for Color.RED.
|
static GGNavigationListener.ScreenOrientation |
REPORT
Constant for setScreenOrientation().
|
static GGNavigationListener.ScreenOrientation |
RESTART
Constant for setScreenOrientation().
|
static int |
TRANSPARENT
Short for Color.TRANSPARENT.
|
static int |
WHITE
Short for Color.WHITE.
|
static int |
YELLOW
Short for Color.YELLOW.
|
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
Constructor and Description |
---|
GameGrid()
Same as GameGrid(boolean isFullScreen, WindowZoom windowZoom)
with isFullScreen = false and windowZoom = null,
so the graphics window is a square and images are not zoomed.
|
GameGrid(boolean isFullScreen,
GameGrid.WindowZoom windowZoom)
Constructs a game activity with no active navigation buttons,
no visible grid (transparent) and no background image.
|
GameGrid(GameGrid.WindowZoom windowZoom)
Same as GameGrid(boolean isFullScreen, WindowZoom windowZoom) with
isFullScreen = false, so the graphics window is a square.
|
GameGrid(int borderColor)
Same as GameGrid(int borderColor, booolean isNavigation, boolean isFullscreen, WindowZoom windowZoom)
with isNavigation = false, isFullScreen = false and windowZoom = null,
so the graphics window is a square and images are not zoomed.
|
GameGrid(int borderColor,
boolean isNavigation,
boolean isFullScreen,
GameGrid.WindowZoom windowZoom)
Constructs a game activity with no active navigation buttons,
no visible grid (transparent) and no background image.
|
GameGrid(int borderColor,
GameGrid.WindowZoom windowZoom)
Same as GameGrid(int borderColor, boolean isNavigation, boolean isFullscreen, WindowZoom windowZoom)
with isNavigation = false and isFullScreen = false, so the graphics window is a square.
|
GameGrid(int nbHorzCells,
int nbVertCells,
GameGrid.CellZoom cellZoom)
Same as GameGrid(int nbHorzCells, int nbVertCells, int cellSize),
but the grid size is adapted to fit the current screen and images are
zoomed automatically when loaded.
|
GameGrid(int nbHorzCells,
int nbVertCells,
GameGrid.CellZoom cellZoom,
int gridColor)
Same as GameGrid(int nbHorzCells, int nbVertCells, int cellSize,
int gridColor), but the grid size is adapted to fit the current screen
and images are zoomed automatically when loaded.
|
GameGrid(int nbHorzCells,
int nbVertCells,
GameGrid.CellZoom cellZoom,
int gridColor,
boolean isNavigation)
Same as GameGrid(int nbHorzCells, int nbVertCells, int cellSize,
int gridColor, boolean isNavigation), but the
grid size is adapted to fit the current screen
and images are zoomed automatically when loaded.
|
GameGrid(int nbHorzCells,
int nbVertCells,
GameGrid.CellZoom cellZoom,
int gridColor,
java.lang.String bgImagePath,
boolean isNavigation)
Same as GameGrid(int nbHorzCells, int nbVertCells, int cellSize,
int gridColor, String bgImagePath, boolean isNavigation), but the
grid size is adapted to fit the current screen
and images are zoomed automatically when loaded.
|
GameGrid(int nbHorzCells,
int nbVertCells,
int cellSize)
Constructs a game activity with no active navigation buttons,
no visible grid (transparent) and no background image.
|
GameGrid(int nbHorzCells,
int nbVertCells,
int cellSize,
int gridColor)
Constructs a game activity with no active navigation buttons
and possibly a visible grid, but no background image.
|
GameGrid(int nbHorzCells,
int nbVertCells,
int cellSize,
int gridColor,
boolean isNavigation)
Constructs a game activity with possibly a visible grid,
possibly active navitation buttons, but no background image.
|
GameGrid(int nbHorzCells,
int nbVertCells,
int cellSize,
int gridColor,
java.lang.String bgImagePath,
boolean isNavigation)
Constructs a game activity with possibly active navigation buttons,
possibly a visible grid and possibly a background image.
|
GameGrid(java.lang.String bgImagePath)
Same as GameGrid(String bgImagePath, boolean isNavigation,
boolean isFullScreen, WindowZoom windowZoom)
with isNavigation = false, isFullScreen = false and windowZoom = null,
so the graphics window is a square and images are not zoomed
|
GameGrid(java.lang.String bgImagePath,
boolean isNavigation,
boolean isFullScreen,
GameGrid.WindowZoom windowZoom)
Constructs a game activity with no visible grid (transparent)
possibly a background image and possibly active navitation buttons.
|
GameGrid(java.lang.String bgImagePath,
GameGrid.WindowZoom windowZoom)
Same as GameGrid(String bgImagePath, boolean isNavigation,
boolean isFullScreen, WindowZoom windowZoom)
with isNavigation = false, isFullScreen = false,
so the graphics window is a square.
|
Modifier and Type | Method and Description |
---|---|
void |
act()
Empty method called in every simulation cycle after all actor act() calls.
|
void |
actAll()
Invokes all actor's act() methods in the order of the scene
and draws the new game situation.
|
void |
addActListener(GGActListener listener)
Registers the given GGActListener to get act() events.
|
void |
addActor(Actor actor,
Location location)
Same as addActor(Actor actor, Location location, double direction) with
direction = 0 (to east).
|
void |
addActor(Actor actor,
Location location,
double direction)
Adds a new actor at given starting position with given moving direction
to the scene.
|
void |
addActor(Actor actor,
Location location,
Location.CompassDirection compassDir)
Same as addActor(Actor actor, Location location, double direction)
with compass direction.
|
void |
addActorNoRefresh(Actor actor,
Location location)
Same as addActor(Actor actor, Location location), but the game grid window
is not refreshed automatically.
|
void |
addActorNoRefresh(Actor actor,
Location location,
double direction)
Same as addActor(Actor actor, Location location, double direction),
but the game grid window is not refreshed automatically.
|
void |
addFlingListener(GGFlingListener listener)
Adds a GGFlingListener to get notifications from fling events.
|
void |
addMultiTouchListener(GGMultiTouchListener listener,
int multiTouchEventMask)
Adds a GGMultiTouchListener to get notifications from multi-touch events.
|
void |
addNavigationListener(GGNavigationListener listener)
Registers a navigation listener to get notifications when the smartphones
buttons are used (BACK, HOME, VOLUME_INCREASE and VOLUME_DECREASE).
|
void |
addOrientationListener(GGOrientationListener listener)
Registers a GGOrientationListener to get notifications when the smartphones
changes orientation from LANDSCAPE to PORTRAIT or vice vera and the
device orientation is not fixed.
|
void |
addSoftButton(int buttonId,
java.lang.String label)
Adds one of four soft button with given id and button label at the bottom of
the view.
|
void |
addSoftButtonListener(GGSoftButtonListener listener)
Adds a GGSoftButtonListener to get notifications soft button events.
|
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 |
addTouchListener(GGTouchListener listener,
int touchEventMask)
Adds a GGTouchListener to get notifications from touch events.
|
static GameGrid.CellZoom |
cellZoom(int cellSize)
Returns a CellZoom reference to be used as constructor parameter
for apps based on grids.
|
static boolean |
copyBinary(java.io.InputStream in,
java.lang.String outPath,
boolean close)
Takes the given input stream and copies the data byte-by-byte to an output file.
|
android.media.MediaPlayer |
createMediaPlayer(java.lang.String soundResource)
Creates and prepares a MediaPlayer instance with given audio path name.
|
GGTileMap |
createTileMap(int nbHorzTiles,
int nbVertTiles,
int tileWidth,
int tileHeight)
Creates/Replaces a TileMap with the specified number of horizontal and vertical
tiles.
|
static void |
delay(long timeout)
Halts the current thread for the given time.
|
void |
doPause()
Pause the simulation cycling.
|
void |
doReset()
If still running, calls doPause() and restores actors
to their initializing state.
|
void |
doRun()
Starts the simulation cycling.
|
void |
doStep()
Runs the the simulation loop once.
|
void |
enableKill(boolean b)
Enables/disables brute force killing of process when onPause() is called.
|
java.util.ArrayList<android.hardware.Sensor> |
enumerateSensors()
Retrieves the list of all available sensors.
|
java.util.ArrayList<java.lang.String> |
enumerateSensorSpecs()
Retrieves the sensor specifications of all available sensors.
|
void |
fail(java.lang.String msg)
Displays the given message in the status line and terminates the
process shortly after.
|
void |
fail(java.lang.String msg1,
java.lang.String msg2)
Displays the two given messages in the status line and terminates the
process shortly after.
|
java.util.ArrayList<Actor> |
getActors()
Returns all actors that are part of the game grid.
|
java.util.ArrayList<Actor> |
getActors(java.lang.Class clazz)
Returns all actors of the specified class that are part of the game grid.
|
java.util.ArrayList<Actor> |
getActorsAt(Location location)
Returns all actors at the given location that are part of the game grid.
|
java.util.ArrayList<Actor> |
getActorsAt(Location location,
java.lang.Class clazz)
Returns all actors of given type at given location that are part of
the game grid.
|
java.lang.String |
getAppName()
Returns the app name of the current application.
|
float |
getAudioVolume()
Returns the current relative audio volume set by the sound control
(0: mute, 1: maximal sound volume)
|
GGBackground |
getBg()
Provides access to the GGBackground instance.
|
java.lang.String |
getBgImagePath()
Returns to path to the background image file.
|
android.graphics.Point |
getBgImagePos()
Returns the x-y-coordinates of the upper left corner of the background image
with respect to the playground pixel coordinates.
|
int |
getBgImagePosX()
Returns the x-coordinate of the upper left corner of the background image
with respect to the playground pixel coordinates.
|
int |
getBgImagePosY()
Returns the y-coordinate of the upper left corner of the background image
with respect to the playground pixel coordinates.
|
android.graphics.Canvas |
getCanvas()
Provides access to the canvas of the current activity.
|
int |
getCellSize()
Returns the size of a cell (in pixels).
|
android.content.Context |
getContext()
Provides access to the Context instance of the current activity.
|
java.util.ArrayList<Location> |
getDiagonalLocations(Location location,
boolean up)
Returns a list of all grid locations that are on the diagonal line
through the given location.
|
java.util.ArrayList<Location> |
getEmptyLocations()
Returns a list of all locations not occupied by actors.
|
android.graphics.Bitmap |
getFrameBuffer()
Provides access to the offscreen buffer of the current activity.
|
int |
getGridColor()
Returns the color of the grid.
|
android.graphics.Bitmap |
getImage()
Returns the Bitmap reference of the current GameGrid window including
the background and all actors.
|
java.util.ArrayList<GameGrid.SysInfo> |
getInstalledApps(boolean includeSysPackages,
boolean isPackageSort)
Returns information about installed applications.
|
java.util.ArrayList<Location> |
getLineLocations(Location loc1,
Location loc2,
boolean interjacent)
Returns a list of cell grid locations whose cell centers are exactly on the
the line through the centers of loc1 and loc1.
|
int |
getNbCycles()
Returns the number of simulation cycles since last reset.
|
int |
getNbHorzCells()
Returns the horizontal number of cells.
|
int |
getNbHorzPix()
Returns the horizontal number of pixels of the playground.
|
int |
getNbVertCells()
Returns the vertical number of cells.
|
int |
getNbVertPix()
Returns the vertical number of pixels of the playground.
|
int |
getNumberOfActors()
Returns total number of actors in the scene.
|
int |
getNumberOfActors(java.lang.Class clazz)
Returns number of actors of specified class.
|
int |
getNumberOfActorsAt(Location location)
Returns number of actors at specified location.
|
int |
getNumberOfActorsAt(Location location,
java.lang.Class clazz)
Returns number of actors of specified class at specified location.
|
java.util.ArrayList<Location> |
getOccupiedLocations()
Returns a list of all locations occupied by actors.
|
Actor |
getOneActor(java.lang.Class clazz)
Returns the actor of the specified class
that is part of the game grid and is on top in the paint order.
|
Actor |
getOneActorAt(Location location)
Returns the actor at the specified location
that is part of the game grid and is on top in the paint order.
|
Actor |
getOneActorAt(Location location,
java.lang.Class clazz)
Returns the actor of the specified class at the specified location
that is part of the game grid and is on top in the paint order.
|
java.util.ArrayList<Actor> |
getPaintOrderList()
Returns a list with actor references in the order they are painted.
|
java.util.ArrayList<Actor> |
getPaintOrderList(java.lang.Class clazz)
Returns a list with actor references of the given class in the order they
are painted.
|
GGPanel |
getPanel()
Sets the float user coordinate system of the GGPanel to (xmin, xmax, ymin, ymax) =
(0, 1, 0, 1) and returns a reference to the GGPanel.
|
GGPanel |
getPanel(double ymin,
double ymax,
double xratio)
Sets the user coordinate system and returns a reference to the GGPanel
(x from left to right, y from bottom to top).
|
GGPanel |
getPanel(double xmin,
double xmax,
double ymin,
double ymax)
Sets the user coordinate system and returns a reference to the GGPanel
(x from left to right, y from bottom to top).
|
GGParams |
getParams()
Returns a reference to the GGParam instance used when the
application is started with a launcher app (see GGParams class
for more information).
|
int |
getPgHeight()
Returns the height (vertical size) of the playground in pixel units.
|
int |
getPgWidth()
Returns the width (horizontal size) of the playground in pixel units.
|
double |
getRandomDirection()
Returns a random direction 0..360 degrees.
|
Location |
getRandomEmptyLocation()
Returns an empty random location within the game grid.
|
Location |
getRandomLocation()
Returns a random location within the game grid.
|
java.lang.String |
getRotation()
Returns the rotation string used to detect the difference
between a coordinate system that is fixed to the device
and a coordinate system that depends on the current device
orientation.
|
int |
getScreenOrientation()
Returns the current screen orientation (1: portrait, 2: landscape).
|
double |
getScreenResolution(boolean metric)
Returns the screen resolution in pixel/inch or pixel/m
|
java.lang.String |
getScreenRotation()
Returns a description of the current screen rotation.
|
int |
getSimulationPeriod()
Returns the simulation period.
|
GGTileMap |
getTileMap()
Returns the reference to the GGTileMap.
|
static java.lang.String |
getTime()
Returns the current system time as formatted string.
|
java.util.ArrayList<Actor> |
getTouchedActors(java.lang.Class clazz)
Returns a list with actor references of all actors of the given class whose
touched area (of type IMAGE, RECTANGLE or CIRCLE) intersects with the current mouse
touch position.
|
Location |
getTouchLocation()
Returns the cell location of the cell under the touch position or null, if
the game grid is not visible.
|
android.graphics.Point |
getTouchPosition()
Returns the current touch position or null, if
there is currently no touch.
|
android.graphics.Point |
getUl()
Returns the coordinates of the upper-left vertex of the game grid with
respect to the screen.
|
int |
getUlx()
Returns the x-coordinates of the upper-left vertex of the game grid with
respect to the screen.
|
int |
getUly()
Returns the y-coordinates of the upper-left vertex of the game grid with
respect to the screen.
|
java.lang.String |
getVersion()
Returns current version information.
|
android.os.Vibrator |
getVibrator()
Returns the vibrator reference for this context.
|
android.view.View |
getView()
Provides access to the View instance of the current activity.
|
int |
getVirtualPgHeight()
Returns the virtual height (vertical size) of the playground in pixel units.
|
int |
getVirtualPgWidth()
Returns the virtual width (horizontal size) of the playground in pixel units.
|
double |
getZoomFactor()
Returns the current zoom factor (set by setZoomFactor() or
constructor parameters).
|
boolean |
isActorColliding(Actor a1,
Actor a2)
Checks if the two given actors are colliding.
|
boolean |
isAtBorder(Location location)
Returns true, if the given cell location is at the grid border.
|
boolean |
isEmpty(Location location)
Returns true, if there is no actor at specified location.
|
boolean |
isInGrid(Location location)
Returns true, if the given cell location is within the grid.
|
boolean |
isMainAlive()
Returns the state of the main thread.
|
boolean |
isMultiTouchSupported()
Returns device information if multi-touch is supported.
|
boolean |
isOrientationTablet()
Compares the screen orientation and the screen rotation to determine
if the device is a big screen size smartphone or tablet (on tablets
portrait and landscape rotation are inverse).
|
boolean |
isRefreshEnabled()
Checks if the automatic refresh in every simulation cycle is enabled.
|
boolean |
isRunning()
Returns true, if the game is running.
|
boolean |
isTileColliding(Actor a,
Location location)
Checks if the given actor and the tile at the given tile location are colliding.
|
void |
killProcess()
Brute force termination of the app.
|
void |
notifyCreate()
Empty method called last in onCreate().
|
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.
|
java.io.InputStream |
openDrawableResource(java.lang.String filename)
Opens the given raw resource (file in subdirectory res/drawable).
|
java.io.InputStream |
openRawResource(java.lang.String filename)
Opens the given raw resource (file in subdirectory res/raw).
|
int |
pixelToVirtual(int tPixel)
Returns the virtual value (int)(tPixel / zoomFactor) of a pixel coordinate.
|
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 |
playTone(int frequency,
int duration)
Plays a sine wave tone with given frequency and duration.
|
void |
refresh()
Repaints the graphics to show any changes in the offscreen buffer.
|
boolean |
removeActor(Actor actor)
Removes the given actor from the scene, so that act() is not called any more.
|
int |
removeActors(java.lang.Class clazz)
Removes all actors from the specified class, so that act() is not called any more.
|
int |
removeActorsAt(Location location)
Removes all actors at the specified location, so that act() is not called any more.
|
int |
removeActorsAt(Location location,
java.lang.Class clazz)
Removes all actors from the specified class at the specified location,
so that act() is not called any more.
|
int |
removeAllActors()
Removes all actors from the scene, so that act() is not called any more.
|
boolean |
removeFlingListener(GGFlingListener listener)
Removes the given fling listener from the list of registered
fling listeners.
|
boolean |
removeTouchListener(GGTouchListener listener)
Removes the given touch listener from the list of registered
touch listeners.
|
int |
requestBluetoothDiscoverability(int duration)
Shows a modal dialog to request the user to set the device discovarable
for the given amount of time.
|
void |
requestBluetoothEnable()
Shows a modal dialog to request the user to enable Bluetooth.
|
double |
requestDouble(java.lang.String title,
java.lang.String prompt)
Same as requestDouble(String title, String prompt, double init) with no
init value.
|
double |
requestDouble(java.lang.String title,
java.lang.String prompt,
double init)
Opens a modal input dialog with given title, prompt and initial value.
|
float |
requestFloat(java.lang.String title,
java.lang.String prompt)
Same as requestFloat(String title, String prompt, double init) with no
init value.
|
float |
requestFloat(java.lang.String title,
java.lang.String prompt,
float init)
Opens a modal input dialog with given title, prompt and initial value.
|
int |
requestInt(java.lang.String title,
java.lang.String prompt)
Same as requestInt(String title, String prompt, double init) with no
init value.
|
int |
requestInt(java.lang.String title,
java.lang.String prompt,
int init)
Opens a modal input dialog with given title, prompt and initial value.
|
long |
requestLong(java.lang.String title,
java.lang.String prompt)
Same as requestLong(String title, String prompt, double init) with no
init value.
|
long |
requestLong(java.lang.String title,
java.lang.String prompt,
long init)
Opens a modal input dialog with given title, prompt and initial value.
|
java.lang.String |
requestString(java.lang.String title,
java.lang.String prompt)
Same as requestString(String title, String prompt, double init) with no
init value.
|
java.lang.String |
requestString(java.lang.String title,
java.lang.String prompt,
java.lang.String init)
Opens a modal input dialog with given title, prompt and initial value.
|
void |
reset()
Empty method called when the reset button is hit or doReset() is called.
|
Actor |
reverseSceneOrder(java.util.ArrayList<Actor> actors)
Reverses the order of the given actor list in the corresponding
scene list.
|
void |
sendSMS(java.lang.String phoneNumber,
java.lang.String message)
Sends a SMS with given message to the given recipient.
|
void |
setActEnabled(boolean enable)
Enables/disables the simulation cycle momentarily.
|
void |
setActOrder(java.lang.Class... classes)
Set the act order of objects in the scene.
|
void |
setActorOnBottom(Actor actor)
Puts the given actor at first place in the corresponding scene list,
in order to act last and to be drawn on the bottom of other actors
of the same class.
|
void |
setActorOnTop(Actor actor)
Puts the given actor at last place in the corresponding scene list,
in order to act first and to be drawn on top of other actors
of the same class.
|
void |
setBgImagePath(java.lang.String bgImagePath)
Sets the path to the background image file.
|
void |
setBgImagePos(android.graphics.Point point)
Sets the x-y-coordinate of the upper left corner of the background image
with respect to the playground pixel coordinates.
|
void |
setBgImagePosX(int x)
Sets the x-coordinate of the upper left corner of the background image
with respect to the playground pixel coordinates.
|
void |
setBgImagePosY(int y)
Sets the y-coordinate of the upper left corner of the background image
with respect to the playground pixel coordinates.
|
void |
setBorderColor(int color)
Sets the color of the frame border.
|
void |
setCleanupEnabled(boolean enable)
Enables/disables automatic cleanup of game grid (all
actors removed from game grid, default simulationPeriod)
when game grid is reinitialized (e.g. when orientation
changes).
|
void |
setGridColor(int color)
Sets the color of the grid and reconstructs the background.
|
void |
setMultiTouchEnabled(boolean enable)
Enable/disable all multi-touch event callbacks.
|
void |
setNavigationNotifications(int type)
Enables/disables automatic toast notifications when the hardware
button-navigation is active.
|
void |
setNbRotSprites(int nbSprites)
Sets the new number of rotated sprite images in the internal sprite store
(default 60).
|
void |
setPaintOrder(java.lang.Class... classes)
Sets the paint order of objects in the game grid.
|
void |
setRefreshEnabled(boolean enable)
Enables/disables the automatic repainting of the graphics in every simulation
cycle.
|
void |
setSceneOrder(java.util.ArrayList<Actor> actors)
Sets the act and paint order of the actors in the given list by
rearraging their scene list to the order in the given list.
|
void |
setScreenOrientation(GGNavigationListener.ScreenOrientation orientation)
Sets a fixed screen orientation.
|
void |
setSimulationPeriod(int ms)
Sets the simulation period.
|
void |
setSoftButtonVisible(int buttonId,
boolean visible)
Sets the visibility of a soft button that has been previously added.
|
void |
setTitleText(java.lang.String msg)
Shows a title bar notification with given text and default
game grid icon.
|
void |
setTitleText(java.lang.String msg,
int icon)
Shows a title bar notification with given text and icon from resources.
|
void |
setTitleText(java.lang.String msg,
java.lang.String iconName)
Shows a title bar notification with given text and icon name
(without extension).
|
void |
setTouchEnabled(boolean enable)
Enable/disable all touch event callbacks (also fling events).
|
void |
setWakeLockEnabled(boolean enable)
Enables/disables the lock of the wake state.
|
void |
setZoomFactor(double zoomFactor)
Enables/disables the auto zoom facility and sets the zoom factor
to the given value.
|
Actor |
shiftSceneOrder(java.util.ArrayList<Actor> actors,
boolean forward)
Shifts (rolls) the actors of the given actor list in the corresponding
scene list forward or backward.
|
void |
showToast(java.lang.String text)
Same as showToast(text, position, isLong) with system defined position and
isLong = false.
|
void |
showToast(java.lang.String text,
boolean isLong)
Same as showToast(text, position, isLong) with system defined position.
|
void |
showToast(java.lang.String text,
android.graphics.Point position)
Same as showToast(text, position, isLong) with isLong = false.
|
void |
showToast(java.lang.String text,
android.graphics.Point position,
boolean isLong)
Displays an Android "toast" message (notification that pops
up shortly).
|
void |
superOnPause()
Calls onPause() of the super class.
|
Location |
toLocation(int x,
int y)
Returns the location (cell indices) of the cell where the point
with given coordinates resides.
|
Location |
toLocation(android.graphics.Point pt)
Returns the location (cell indices) of the cell where the given point
resides.
|
Location |
toLocationInGrid(int x,
int y)
Returns the location (cell indices) of the cell where the point
with given coordinates resides.
|
Location |
toLocationInGrid(android.graphics.Point pt)
Returns the location (cell indices) of the cell where the given point
resides.
|
android.graphics.Point |
toPoint(Location location)
Returns the x-y-coordinates of the center of the cell with given
location (cell indices).
|
int |
virtualToPixel(int tVirtual)
Returns the pixel value tVirtual * zoomFactor of a virtual coordinate.
|
static GameGrid.WindowZoom |
windowZoom(int windowSize)
Returns a WindowZoom reference to be used as constructor parameter
for apps based on pixels.
|
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 static final int BLACK
public static final int BLUE
public static final int CYAN
public static final int DKGRAY
public static final int GRAY
public static final int GREEN
public static final int LTGRAY
public static final int MAGENTA
public static final int RED
public static final int TRANSPARENT
public static final int WHITE
public static final int YELLOW
public static final GGNavigationListener.ScreenOrientation LANDSCAPE
public static final GGNavigationListener.ScreenOrientation PORTRAIT
public static final GGNavigationListener.ScreenOrientation KILLPROCESS
public static final GGNavigationListener.ScreenOrientation RESTART
public static final GGNavigationListener.ScreenOrientation REPORT
public static final java.lang.Object monitor
public static GameGrid myGameGrid
public GameGrid()
public GameGrid(GameGrid.WindowZoom windowZoom)
windowZoom
- a WindowZoom reference to define the zoom factor. Use
windowZoom(int windowSize) to create it; if null, the images are not zoomedpublic GameGrid(boolean isFullScreen, GameGrid.WindowZoom windowZoom)
isFullScreen
- if true, the windows is the maximum rectangle that fits the screen;
otherwise it is the maximum square that fits the screenwindowZoom
- a WindowZoom reference to define the zoom factor. Use
windowZoom(int windowSize) to create it; if null, the images are not zoomedpublic GameGrid(int borderColor)
borderColor
- the color of the borderpublic GameGrid(int borderColor, GameGrid.WindowZoom windowZoom)
borderColor
- the color of the borderwindowZoom
- a WindowZoom reference to define the zoom factor. Use
windowZoom(int windowSize) to create it; if null, the images are not zoomedpublic GameGrid(int borderColor, boolean isNavigation, boolean isFullScreen, GameGrid.WindowZoom windowZoom)
borderColor
- the color of the borderisFullScreen
- if true, the windows is the maximum rectangle that fits the screen;
otherwise it is the maximum square that fits the screenwindowZoom
- a WindowZoom reference to define the zoom factor. Use
windowZoom(int windowSize) to create it; if null, the images are not zoomedpublic GameGrid(java.lang.String bgImagePath)
bgImagePath
- the path to a background image (if null, no background image)public GameGrid(java.lang.String bgImagePath, GameGrid.WindowZoom windowZoom)
bgImagePath
- the path to a background image (if null, no background image)windowZoom
- a WindowZoom reference to define the zoom factor. Use
windowZoom(int windowSize) to create it; if null, the images are not zoomedpublic GameGrid(java.lang.String bgImagePath, boolean isNavigation, boolean isFullScreen, GameGrid.WindowZoom windowZoom)
bgImagePath
- the path to a background image (if null, no background image)isNavigation
- if true, the standard smartphone's buttons are active for navigationisFullScreen
- if true, the windows is the maximum rectangle that fits the screen;
otherwise it is the maximum square that fits the screenwindowZoom
- a WindowZoom reference to define the zoom factor. Use
windowZoom(int windowSize) to create it; if null, the images are not zoomedpublic GameGrid(int nbHorzCells, int nbVertCells, int cellSize)
nbHorzCells
- the number of horizontal cellsnbVertCells
- the number of vertical cellscellSize
- the requested cell size in pixels, if >0 the cell size
is fixed even if the game grid does not fit the screen,
if 0 the size is adjusted to fit the screen, changing when the screen is
turned. The cell size can be requested by calling getCellSize()public GameGrid(int nbHorzCells, int nbVertCells, GameGrid.CellZoom cellZoom)
nbHorzCells
- the number of horizontal cellsnbVertCells
- the number of vertical cellscellZoom
- a CellZoom reference to define the zoom factor. Use
cellZoom(int cellSize) to create it; if null, the images are not zoomedpublic GameGrid(int nbHorzCells, int nbVertCells, int cellSize, int gridColor)
nbHorzCells
- the number of horizontal cellsnbVertCells
- the number of vertical cellscellSize
- the requested cell size in pixels, if >0 the cell size
is fixed even if the game grid does not fit the screen,
if 0 the size is adjusted to fit the screen, changing when the screen is
turned. The cell size can be requested by calling getCellSize()gridColor
- the color of the grid (if Color.TRANSPARENT, no grid is shown)public GameGrid(int nbHorzCells, int nbVertCells, GameGrid.CellZoom cellZoom, int gridColor)
nbHorzCells
- the number of horizontal cellsnbVertCells
- the number of vertical cellscellZoom
- a CellZoom reference to define the zoom factor. Use
cellZoom(int cellSize) to create it; if null, the images are not zoomedgridColor
- the color of the grid (if Color.TRANSPARENT, no grid is shown)public GameGrid(int nbHorzCells, int nbVertCells, int cellSize, int gridColor, boolean isNavigation)
nbHorzCells
- the number of horizontal cellsnbVertCells
- the number of vertical cellscellSize
- the requested cell size in pixels, if >0 the cell size
is fixed even if the game grid does not fit the screen,
if 0 the size is adjusted to fit the screen, changing when the screen is
turned. The cell size can be requested by calling getCellSize()gridColor
- the color of the grid (if Color.TRANSPARENT, no grid is shown)isNavigation
- if true, the standard smartphone's buttons are active for navigationpublic GameGrid(int nbHorzCells, int nbVertCells, GameGrid.CellZoom cellZoom, int gridColor, boolean isNavigation)
nbHorzCells
- the number of horizontal cellsnbVertCells
- the number of vertical cellscellZoom
- a CellZoom reference to define the zoom factor. Use
cellZoom(int cellSize) to create it; if null, the images are not zoomedgridColor
- the color of the grid (if Color.TRANSPARENT, no grid is shown)isNavigation
- if true, the standard smartphone's buttons are active for navigationpublic GameGrid(int nbHorzCells, int nbVertCells, int cellSize, int gridColor, java.lang.String bgImagePath, boolean isNavigation)
nbHorzCells
- the number of horizontal cellsnbVertCells
- the number of vertical cellscellSize
- the requested cell size in pixels, if >0 the cell size
is fixed even if the game grid does not fit the screen,
if 0 the size is adjusted to fit the screen, changing when the screen is
turned. The cell size can be requested by calling getCellSize()gridColor
- the color of the grid (if Color.TRANSPARENT, no grid is shown)bgImagePath
- the path to a background image (if null, no background image)isNavigation
- if true, the standard smartphone's buttons are active for navigationpublic GameGrid(int nbHorzCells, int nbVertCells, GameGrid.CellZoom cellZoom, int gridColor, java.lang.String bgImagePath, boolean isNavigation)
nbHorzCells
- the number of horizontal cellsnbVertCells
- the number of vertical cellscellZoom
- a CellZoom reference to define the zoom factor. Use
cellZoom(int cellSize) to create it; if null, the images are not zoomedgridColor
- the color of the grid (if Color.TRANSPARENT, no grid is shown)bgImagePath
- the path to a background image (if null, no background image)isNavigation
- if true, the standard smartphone's buttons are active for navigationpublic java.lang.String getBgImagePath()
public void setBgImagePath(java.lang.String bgImagePath)
bgImagePath
- the path to the image file; if null, no background
image is assumedpublic int getBgImagePosX()
public void setBgImagePosX(int x)
x
- the ulx of the background imagepublic int getBgImagePosY()
public void setBgImagePosY(int y)
y
- the ULY of the background imagepublic android.graphics.Point getBgImagePos()
public void setBgImagePos(android.graphics.Point point)
point
- the ulx/uly of the background imagepublic int getNbHorzCells()
public int getNbVertCells()
public int getGridColor()
public void setGridColor(int color)
color
- the grid color; Color.TRANSPARENT, if no grid is desiredpublic void setBorderColor(int color)
color
- the color of the surrounding border (TRANSPARENT for no border)public int getNbHorzPix()
public int getNbVertPix()
public int getPgWidth()
public int getPgHeight()
public int getVirtualPgWidth()
public int getVirtualPgHeight()
public int getCellSize()
public void setRefreshEnabled(boolean enable)
enable
- if true, the automatic refresh is enabled; otherwise disabled.public boolean isRefreshEnabled()
public void refresh()
public GGPanel getPanel()
public GGPanel getPanel(double xmin, double xmax, double ymin, double ymax)
xmin
- x-axis value at leftxmax
- x-axis value at rightymin
- y-axis value at bottomymax
- y-axis value at toppublic GGPanel getPanel(double ymin, double ymax, double xratio)
ymin
- y-axis value at bottomymax
- y-axis value at topxratio
- the fractional part of window width (x direction) where
the origin is placednpublic void notifyCreate()
public void requestBluetoothEnable()
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
public int requestBluetoothDiscoverability(int duration)
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
duration
- the new duration for discoverablity in seconds (0..300 s).
0 will set the default duration of 120 s.public void addSoftButton(int buttonId, java.lang.String label)
buttonId
- the number of the button (0..3), 0 is the most left
button, 3 the most right buttonlabel
- the text shown on the button (max 4 chars)public void setSoftButtonVisible(int buttonId, boolean visible)
buttonId
- the number of the button (0..3), 0 is the most left
button, 3 the most right buttonvisible
- if true, the button becomes visible; otherwise the
button becomes invisible)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 static void delay(long timeout)
timeout
- the time (in ms) the current thread sleepspublic boolean isMainAlive()
public void superOnPause()
public android.graphics.Bitmap getFrameBuffer()
public android.graphics.Canvas getCanvas()
public GGBackground getBg()
public android.graphics.Point getTouchPosition()
public android.graphics.Point toPoint(Location location)
location
- the indices of the cellpublic Location toLocation(android.graphics.Point pt)
pt
- a point of pixels coordinatespublic Location toLocation(int x, int y)
x
- x-coordinate (in pixels)y
- y-coordinate (in pixels)public Location toLocationInGrid(android.graphics.Point pt)
pt
- a point of pixels coordinatespublic Location toLocationInGrid(int x, int y)
x
- x-coordinate (in pixels)y
- y-coordinate (in pixels)public boolean isInGrid(Location location)
public boolean isAtBorder(Location location)
public java.util.ArrayList<Location> getOccupiedLocations()
public java.util.ArrayList<Location> getEmptyLocations()
public java.util.ArrayList<Actor> getActors()
public java.util.ArrayList<Actor> getActorsAt(Location location, java.lang.Class clazz)
location
- the location of the cellclazz
- class type of the actors to be returned (e.g. Fish.class),
if clazz is null, all actors are returnedpublic java.util.ArrayList<Actor> getActorsAt(Location location)
public java.util.ArrayList<Actor> getActors(java.lang.Class clazz)
clazz
- the class of the actors to look for, if null all actors are returnedpublic Actor getOneActorAt(Location location, java.lang.Class clazz)
location
- the location of the cellclazz
- the class of the actors to look for, if null all actors are consideredpublic Actor getOneActor(java.lang.Class clazz)
clazz
- the class of the actors to look for, if null all actors are consideredpublic Actor getOneActorAt(Location location)
location
- the location of the cellpublic int getNumberOfActors()
public int getNumberOfActorsAt(Location location)
public int getNumberOfActorsAt(Location location, java.lang.Class clazz)
public int getNumberOfActors(java.lang.Class clazz)
public boolean isEmpty(Location location)
public boolean removeActor(Actor actor)
actor
- the actor to be removedpublic int removeAllActors()
public int removeActors(java.lang.Class clazz)
clazz
- class of the actors to be removed, if null all actors are removedpublic int removeActorsAt(Location location, java.lang.Class clazz)
location
- the location of the cellclazz
- class of the actors to be removed, if null all actors are removedpublic int removeActorsAt(Location location)
location
- the location of the cellpublic Location getRandomLocation()
public double getRandomDirection()
public Location getRandomEmptyLocation()
public Location getTouchLocation()
public boolean isRunning()
public void actAll()
public void act()
act
in interface GGActListener
public void setActOrder(java.lang.Class... classes)
classes
- the classes in desired act orderpublic void setPaintOrder(java.lang.Class... classes)
classes
- the classes in desired paint orderpublic void setActorOnTop(Actor actor)
actor
- the actor to put on toppublic void setActorOnBottom(Actor actor)
actor
- the actor to put on the bottompublic Actor shiftSceneOrder(java.util.ArrayList<Actor> actors, boolean forward)
actors
- a list of actors to shiftforward
- if true, shifts to the right (forward); otherwise
shifts to the left (backward)public Actor reverseSceneOrder(java.util.ArrayList<Actor> actors)
actors
- a list of actors to shiftpublic void setSceneOrder(java.util.ArrayList<Actor> actors)
actors
- a list of actors to rearrangepublic java.util.ArrayList<Actor> getPaintOrderList(java.lang.Class clazz)
clazz
- the class of actors included in the list; if null, all actors are includedpublic java.util.ArrayList<Actor> getPaintOrderList()
public java.util.ArrayList<Actor> getTouchedActors(java.lang.Class clazz)
clazz
- the class of actors checked for a touch. If null, all
actors are checked.public void fail(java.lang.String msg)
msg
- the message to displaypublic void fail(java.lang.String msg1, java.lang.String msg2)
msg1
- the first message to displaymsg2
- the second message to displaypublic void addActorNoRefresh(Actor actor, Location location)
actor
- the actor to be added at the end of the scene listlocation
- the location of the actor (cell indices, value copy)public void addActorNoRefresh(Actor actor, Location location, double direction)
actor
- the actor to be added at the end of the scene listlocation
- the location of the actor (cell indices, value copy)direction
- the direction (clockwise in degrees, 0 to east)public void addActor(Actor actor, Location location, double direction)
actor
- the actor to be added at the end of the scene listlocation
- the location of the actor (cell indices, value copy)direction
- the direction (clockwise in degrees, 0 to east)public void addActor(Actor actor, Location location)
actor
- the actor to be added at the end of the scene listlocation
- the location of the actor (cell indices, value copy)public void addActor(Actor actor, Location location, Location.CompassDirection compassDir)
actor
- the actor to be added at the end of the scene listlocation
- the location of the actor (cell indices)compassDir
- the compass directionpublic void doReset()
public void doRun()
public void doPause()
public void doStep()
public void reset()
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 setTitleText(java.lang.String msg)
msg
- the text to displaypublic void setTitleText(java.lang.String msg, java.lang.String iconName)
msg
- the text to displayiconName
- the file name of the icon to display (must reside in
res/drawable directory)public void setTitleText(java.lang.String msg, int icon)
msg
- the text to displayicon
- the icon resource to displaypublic void setSimulationPeriod(int ms)
ms
- the simulation period in milliseconds.public int getSimulationPeriod()
public static java.lang.String getTime()
public void addActListener(GGActListener listener)
listener
- the GGActListener to registerpublic void addTouchListener(GGTouchListener listener, int touchEventMask)
listener
- the GGTouchListener to registertouchEventMask
- an OR-combinaton of constants defined in class GGTouchpublic void addMultiTouchListener(GGMultiTouchListener listener, int multiTouchEventMask)
listener
- the GGMultiTouchListener to registermultiTouchEventMask
- an OR-combinaton of constants defined in class GGMultiTouchpublic void addFlingListener(GGFlingListener listener)
listener
- the GGFlingListener to registerpublic boolean removeTouchListener(GGTouchListener listener)
listener
- the listener to removepublic boolean removeFlingListener(GGFlingListener listener)
listener
- the listener to removepublic int getUlx()
public int getUly()
public android.graphics.Point getUl()
public java.util.ArrayList<Location> getDiagonalLocations(Location location, boolean up)
location
- the location where the diagonal line is fixedup
- if true, the increasing diagonal line (y = x + b) is used; otherwise
the decreasing diagonal line (y = -x + b) is usedpublic java.util.ArrayList<Location> getLineLocations(Location loc1, Location loc2, boolean interjacent)
loc1
- the location of the first cellloc2
- the location of the second cellinterjacent
- if true, only location between loc1 and loc2 are
includedpublic boolean isActorColliding(Actor a1, Actor a2)
a1
- the first actora2
- the second actorpublic void addSoftButtonListener(GGSoftButtonListener listener)
listener
- the GGSoftButtonListener to register; null, to disable
a prevously registered listenerpublic void setTouchEnabled(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 void showToast(java.lang.String text, android.graphics.Point position, boolean isLong)
text
- the message to displayposition
- the upper left vertex of the notification windowisLong
- if true, the display duration is somewhat longerpublic void showToast(java.lang.String text, android.graphics.Point position)
text
- the message to displayposition
- the upper left vertex of the notification windowpublic void showToast(java.lang.String text, boolean isLong)
text
- the message to displayisLong
- if true, the display duration is somewhat longerpublic void showToast(java.lang.String text)
text
- the message to displaypublic android.view.View getView()
public android.content.Context getContext()
public void enableKill(boolean b)
b
- if true, killProcess is enabled (default); otherwise disabledpublic void killProcess()
public void setScreenOrientation(GGNavigationListener.ScreenOrientation orientation)
orientation
- one the constants defined in interface GGNavigationListenerGGNavigationListener
public int requestInt(java.lang.String title, java.lang.String prompt, int init)
title
- the title of the dialog boxprompt
- the prompt in the dialog boxinit
- a proposal for the user input valuepublic long requestLong(java.lang.String title, java.lang.String prompt, long init)
title
- the title of the dialog boxprompt
- the prompt in the dialog boxinit
- a proposal for the user input valuepublic float requestFloat(java.lang.String title, java.lang.String prompt, float init)
title
- the title of the dialog boxprompt
- the prompt in the dialog boxinit
- a proposal for the user input valuepublic double requestDouble(java.lang.String title, java.lang.String prompt, double init)
title
- the title of the dialog boxprompt
- the prompt in the dialog boxinit
- a proposal for the user input valuepublic java.lang.String requestString(java.lang.String title, java.lang.String prompt, java.lang.String init)
title
- the title of the dialog boxprompt
- the prompt in the dialog boxinit
- a proposal for the user input valuepublic int requestInt(java.lang.String title, java.lang.String prompt)
title
- the title of the dialog boxprompt
- the prompt in the dialog boxpublic long requestLong(java.lang.String title, java.lang.String prompt)
title
- the title of the dialog boxprompt
- the prompt in the dialog boxpublic float requestFloat(java.lang.String title, java.lang.String prompt)
title
- the title of the dialog boxprompt
- the prompt in the dialog boxpublic double requestDouble(java.lang.String title, java.lang.String prompt)
title
- the title of the dialog boxprompt
- the prompt in the dialog boxpublic java.lang.String requestString(java.lang.String title, java.lang.String prompt)
title
- the title of the dialog boxprompt
- the prompt in the dialog boxpublic void addNavigationListener(GGNavigationListener listener)
listener
- the GGNavigationListener to registerpublic void addOrientationListener(GGOrientationListener listener)
listener
- the GGOrientationListener to registerpublic void setActEnabled(boolean enable)
enable
- if true, a running simulation cycle is interrupted; otherwise
a running simulation cycles is reenabledpublic boolean isTileColliding(Actor a, Location location)
a
- the actor to check for collisionlocation
- the tile locationpublic GGTileMap createTileMap(int nbHorzTiles, int nbVertTiles, int tileWidth, int tileHeight)
nbHorzTiles
- the number of horizontal tilesnbVertTiles
- the number of vertical tilestileWidth
- the width of each tile (in pixels)tileHeight
- the height of each tile (in pixels)public GGTileMap getTileMap()
public void setNavigationNotifications(int type)
type
- 0: no notifications shown (default), 1: only startup notification shown
2: all notifications shownpublic android.media.MediaPlayer createMediaPlayer(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 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 java.io.InputStream openRawResource(java.lang.String filename)
filename
- without extensionpublic java.io.InputStream openDrawableResource(java.lang.String filename)
filename
- without extensionpublic float getAudioVolume()
public static boolean copyBinary(java.io.InputStream in, java.lang.String outPath, boolean close)
in
- the input stream where to take the dataoutPath
- the file path where to transfer the data (e.g. "/sdcard/out.mp3")close
- if true, closes the given input stream; otherwise let it openpublic void onCompletion(android.media.MediaPlayer mp)
onCompletion
in interface android.media.MediaPlayer.OnCompletionListener
mp
- the MediaPlayer that terminiatespublic java.lang.String getVersion()
public void playTone(int frequency, int duration)
frequency
- the frequency of the sine wave in Hertzduration
- the duration in mspublic void sendSMS(java.lang.String phoneNumber, java.lang.String message)
<uses-permission android:name="android.permission.SEND_SMS" />
phoneNumber
- the phone number of the recipientmessage
- the SMS message to sendpublic android.os.Vibrator getVibrator()
<uses-permission android:name="android.permission.VIBRATE" />
public void setNbRotSprites(int nbSprites)
nbSprites
- the number of sprites images in the sprite store (1..360)public void setZoomFactor(double zoomFactor)
zoomFactor
- the factor > 0 applied for the image scaling operation;
if 1 (+-1E-3) no zoom transformation (auto zoom disabled, default value).
Pixel coordinates = zoomFactor * virtual coordinatespublic double getZoomFactor()
public static GameGrid.CellZoom cellZoom(int cellSize)
cellSize
- the standard cell size with no zoom (zoom factor = 1)public static GameGrid.WindowZoom windowZoom(int windowSize)
windowSize
- the standard window size with no zoom (zoom factor = 1)public int pixelToVirtual(int tPixel)
tPixel
- the pixel coordinatepublic int virtualToPixel(int tVirtual)
tVirtual
- the virtual coordinatepublic int getScreenOrientation()
public java.lang.String getScreenRotation()
public boolean isOrientationTablet()
public void setCleanupEnabled(boolean enable)
enable
- if true, the game grid is cleaned up (default)public android.graphics.Bitmap getImage()
public java.util.ArrayList<GameGrid.SysInfo> getInstalledApps(boolean includeSysPackages, boolean isPackageSort)
includeSysPackages
- if true, system packages are included tooisPackageSort
- if true, result is sorted by package name; otherwise
sorted by application namepublic java.lang.String getAppName()
public 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 java.util.ArrayList<android.hardware.Sensor> enumerateSensors()
public java.util.ArrayList<java.lang.String> enumerateSensorSpecs()
public double getScreenResolution(boolean metric)
metric
- if true, returns value in metric system (pixel / m); otherwise
returns value in pixel / inchpublic void setWakeLockEnabled(boolean enable)
<uses-permission android:name="android.permission.WAKE_LOCK" />
enable
- if true, wakes up and remain locked; otherwise terminates the
wake lockpublic java.lang.String getRotation()
public int getNbCycles()
public boolean isMultiTouchSupported()
public GGParams getParams()