public abstract class GameEngine extends MainWindow
Version 1.1 of the GameEngine features:
Control.TranslucentShape
Modifier and Type | Field and Description |
---|---|
protected Image |
bgSurface |
static int |
GAME_ENGINE_VERSION |
java.lang.String |
gameCreatorID
Game CreatorID.
|
boolean |
gameDoClearScreen
True if the screen should be cleared before the onPaint() call.
|
protected boolean |
gameHasUI
Must be set to true if the game screen has any control from the totalcross.ui.
|
int |
gameHighscoresSize
Amount of highscores entries in the highscores database.
|
protected boolean |
gameIsRunning
True if the game is running.
|
java.lang.String |
gameName
Name of the game.
|
int |
gameRefreshPeriod
Automatic refresh period in milliseconds.
|
int |
gameVersion
Game version.
|
static int |
NO_AUTO_REFRESH
No automatic refresh.
|
firstTimer
_controlEvent, _dragEvent, _focus, _keyEvent, _mouseEvent, _multiEvent, _penEvent, androidBorderThickness, beepIfOut, blocking, borderStyle, cancelPenUp, canDrag, dragThreshold, fadeOtherWindows, fadeValue, firstFocus, flickEnabled, focusOnPenUp, footerColor, footerH, gradientTitleEndColor, gradientTitleStartColor, headerColor, highlighted, highResPrepared, HORIZONTAL_GRADIENT, ignoreEventOfType, keyHook, lastShiftY, lastSwappedContainer, mainSwapContainer, menubar, multiTouching, needsPaint, NO_BORDER, ORIENTATION_INVERTED, ORIENTATION_LANDSCAPE, ORIENTATION_PORTRAIT, popped, RECT_BORDER, repaintOnSwap, robot, ROUND_BORDER, rTitle, sameBackgroundColor, shiftH, shiftY, SIP_BOTTOM, SIP_HIDE, SIP_SHOW, SIP_TOP, TAB_BORDER, TAB_ONLY_BORDER, tempTitle, title, titleAlign, titleColor, titleFont, titleGap, topMost, VERTICAL_GRADIENT, zStack
alwaysEraseBackground, BACKGROUND_CYLINDRIC_SHADED, BACKGROUND_SHADED, BACKGROUND_SHADED_INV, BACKGROUND_SOLID, backgroundStyle, BORDER_LOWERED, BORDER_NONE, BORDER_RAISED, BORDER_ROUNDED, BORDER_SIMPLE, BORDER_TOP, borderColor, borderRadius, children, controlFound, finishedStart, ignoreOnAddAgain, ignoreOnRemove, insets, lastH, lastScreenWidth, lastW, numChildren, started, tabOrder, tail, TRANSITION_TIME
AFTER, alphaValue, appId, appObj, asContainer, asWindow, backColor, BEFORE, BOTTOM, BOTTOM_OF, BRIGHTER_BACKGROUND, callListenersOnAllTargets, CENTER, CENTER_OF, clearValueInt, clearValueStr, DARKER_BACKGROUND, DP, effect, enableUpdateScreen, esce, eventsEnabled, FILL, fillColor, FIT, floating, fm, fmH, focusHandler, focusLess, focusOnPenDown, focusTraversable, font, FONTSIZE, foreColor, height, ignoreInsets, isHighlighting, isTablet, KEEP, keepDisabled, keepEnabled, LEFT, next, nextTabControl, npParts, offscreen, offscreen0, onEventFirst, parent, PARENTSIZE, PARENTSIZEMAX, PARENTSIZEMIN, PREFERRED, prev, RANGE, repositionAllowed, RIGHT, RIGHT_OF, SAME, SCREENSIZE, SCREENSIZEMAX, SCREENSIZEMIN, setFont, setH, setRel, setW, setX, SETX_NOT_SET, setY, tempW, textShadowColor, TOP, translucentShape, transparentBackground, uiAdjustmentsBasedOnFontHeightIsSupported, uiAndroid, UICONST, uiFlat, uiHolo, uiMaterial, uiVista, visible, width, WILL_RESIZE, x, y
Constructor and Description |
---|
GameEngine()
Creates a new GameEngine
|
Modifier and Type | Method and Description |
---|---|
TextRenderer |
createTextRenderer(Font font,
int foreColor,
java.lang.String text,
int maxDigits)
Create a new TextRenderer.
|
TextRenderer |
createTextRenderer(Font font,
int foreColor,
java.lang.String text,
int maxDigits,
boolean zeroPadding)
Create a new TextRenderer.
|
HighScores |
getHighScores()
Get the game highscores.
|
Options |
getOptions()
Get a new instance of the game options.
|
void |
initUI()
Replace initUI() handling to initialize the engine.
Could not be overloaded. Notifies onGameInit(). |
void |
onEvent(Event evt)
Replace onEvent handling to identify and notify some usefull game
events.
Could not be overloaded. |
void |
onExit()
Replace onExit() handling to shutdown the engine.
Could not be overloaded. Notifies onGameExit(). |
void |
onGameExit()
Event notication called when the game exits.
|
abstract void |
onGameInit()
Event notication called when the game is initialized.
|
void |
onGameStart()
Event notication called when the game mainloop is entered.
|
void |
onGameStop()
Event notication called when the game mainloop is leaved.
|
void |
onKey(KeyEvent evt)
Event notication called when a key event is signaled.
|
void |
onOtherEvent(Event evt)
Event notication called when any other event is signaled.
|
void |
onPaint(Graphics g)
Called at each refresh to draw the current game state
|
void |
onPenDown(PenEvent evt)
Event notication called when a pen down event is signaled.
|
void |
onPenDrag(PenEvent evt)
Event notication called when a pen drag/move event is signaled.
|
void |
onPenUp(PenEvent evt)
Event notication called when a pen up event is signaled.
|
void |
onTimer(TimerEvent evt)
Event notication called when a control event is signaled.
|
void |
refresh()
This function causes an onPaint() call to draw a new frame.
This function has to be called in non time based games to refresh the complete screen. |
protected void |
setGameEngine(GameEngine engine)
Called just after the GameEngine is constructed
|
void |
start()
Must be called to start the game.
|
void |
stop()
Must be called to make the game stop.
|
Image |
useBackground(Image bg)
Use an image as background.
|
_onMinimize, _onRestore, _onTimerTick, addTimer, addTimer, addTimer, addUpdateListener, appEnding, appStarting, exit, getCommandLine, getDefaultFont, getMainWindow, getScreenShot, initFirebaseInstanceIdService, initFirebaseMessagingService, isMainThread, minimize, onMinimize, onRestore, removeTimer, removeUpdateListener, restore, runOnMainThread, runOnMainThread, setDefaultFont, setRect, setUIStyle
_doPaint, _postEvent, destroyZStack, drawHighlight, getBorderStyle, getClientRect, getClientRect, getDefaultDragThreshold, getFocus, getHighlighted, getPopupCount, getPreferredHeight, getPreferredWidth, getTitleFont, getTopMost, handleFocusChangeKeys, isScreenShifted, isSipShown, isSipShown4D, isTopMost, isVisible, loadBehind, makeUnmovable, onClickedOutside, onPopup, onRobotKey, onUnpop, paintTitle, paintWindowBackground, popup, popupMenuBar, popupNonBlocking, postPopup, postPressedEvent, postUnpop, pumpEvents, removeFocus, repaintActiveWindows, resize, resizeHeight, resizeWidth, screenResized, setBorderStyle, setDeviceTitle, setFocus, setGrabPenEvents, setHighlighted, setMenuBar, setOrientation, setSIP, setTitle, setTitleFont, shiftScreen, swap, swapFocus, unpop, validate
add, add, add, add, add, broadcastEvent, clear, fillBackground, findChild, findNearestChild, findNextFocusControl, getBorderRadius, getChildren, getChildrenCount, getFirstChild, getFocusableControls, getInsets, incLastX, incLastY, isPressed, moveFocusToNextControl, moveFocusToNextEditable, onAddAgain, onColorsChanged, onRemove, onSwapFinished, paintChildren, remove, removeAll, setBorderRadius, setEnabled, setFocusTraversable, setHighlighting, setInsets, setPressColor, setPressed, swapToTopmostWindow
_onEvent, addEnabledStateListener, addFocusListener, addFontChangeHandler, addGridListener, addHandler, addHighlightListener, addKeyListener, addListContainerListener, addMouseListener, addMultiTouchListener, addPenListener, addPressListener, addPushNotificationListener, addSizeChangeHandler, addTimer, addTimer, addTimerListener, addValueChangeHandler, addWindowListener, bringToFront, changeHighlighted, contains, drawTranslucentBackground, getAbsoluteRect, getBackColor, getDoEffect, getEffectH, getEffectW, getEffectX, getEffectY, getEventListeners, getFont, getForeColor, getGap, getGraphics, getHeight, getNext, getParent, getParentWindow, getPos, getPressedEvent, getPrev, getRect, getSize, getTextShadowColor, getWidth, getX, getX2, getY, getY2, hadParentScrolled, handleGeographicalFocusChangeKeys, hasFocus, internalSetEnabled, intXYWH, isActionEvent, isChildOf, isDisplayed, isEnabled, isFloating, isInsideOrNear, isObscured, isVisibleAndInside, onBoundsChanged, onFontChanged, onWindowPaintFinished, post, postEvent, releaseScreenShot, removeEnabledStateListener, removeFocusListener, removeGridListener, removeHandler, removeHighlightListener, removeKeyListener, removeListContainerListener, removeMouseListener, removeMultiTouchListener, removePenListener, removePressListener, removePushNotificationListener, removeTimerListener, removeWindowListener, repaint, repaintNow, reposition, reposition, repositionChildren, requestFocus, resetSetPositions, resetStyle, safeRepaintNow, safeUpdateScreen, sendToBack, setBackColor, setBackForeColors, setDoEffect, setFloating, setFocusLess, setFont, setForeColor, setNinePatch, setNinePatch, setRect, setRect, setRect, setSet, setTextShadowColor, setTranslucent, setVisible, showTip, takeInitialScreenShot, takeScreenShot, translateFromOrigin, uiStyleChanged, updateScreen, updateTemporary, willOpenKeyboard
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
_postEvent
public static final int GAME_ENGINE_VERSION
public java.lang.String gameName
public java.lang.String gameCreatorID
public int gameVersion
public int gameHighscoresSize
public static final int NO_AUTO_REFRESH
gameRefreshPeriod
,
Constant Field Valuespublic int gameRefreshPeriod
refresh()
public boolean gameDoClearScreen
protected boolean gameIsRunning
protected boolean gameHasUI
protected Image bgSurface
public abstract void onGameInit()
public void onGameExit()
public void onGameStart()
public void onGameStop()
stop()
public void onTimer(TimerEvent evt)
evt
- control event that occurred.public void onKey(KeyEvent evt)
evt
- key event that occurred.public void onPenDown(PenEvent evt)
evt
- pen event that occurred.public void onPenUp(PenEvent evt)
evt
- pen event that occurred.public void onPenDrag(PenEvent evt)
evt
- pen event that occurred.public void onOtherEvent(Event evt)
evt
- event that occurred.public void onPaint(Graphics g)
public HighScores getHighScores()
public Options getOptions()
public final TextRenderer createTextRenderer(Font font, int foreColor, java.lang.String text, int maxDigits) throws ImageException
font
- to display with.foreColor
- text color, may be null.text
- to render.maxDigits
- digits to display.ImageException
TextRenderer for more information
public final TextRenderer createTextRenderer(Font font, int foreColor, java.lang.String text, int maxDigits, boolean zeroPadding) throws ImageException
font
- to display with.foreColor
- text color, may be null.text
- to render.maxDigits
- digits to display.zeroPadding
- pad with leading zeros.ImageException
TextRenderer for more information
public final void start()
stop()
public final void stop()
public final void refresh()
protected void setGameEngine(GameEngine engine)
public final void initUI()
public final void onExit()
onExit
in class MainWindow
public Image useBackground(Image bg) throws ImageException
ImageException