|
GTGE API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.golden.gamedev.GameObject
public abstract class GameObject
Similar like Game
class except this class is working under
GameEngine
frame work.
GameObject
class is plain same with Game
class, you
can first create the game as Game
class, run it, test it, and
then rename it to GameObject
and attach it to
GameEngine
frame work as one of game entities.
Please read GameEngine
documentation for more information about
how to work with GameObject
class.
GameEngine
,
Game
Field Summary | |
---|---|
BaseGraphics |
bsGraphics
Graphics engine. |
BaseInput |
bsInput
Input engine. |
BaseIO |
bsIO
I/O file engine. |
BaseLoader |
bsLoader
Image loader engine. |
BaseAudio |
bsMusic
Audio engine for music. |
BaseAudio |
bsSound
Audio engine for sound. |
BaseTimer |
bsTimer
Timer engine. |
GameFontManager |
fontManager
Font manager. |
GameEngine |
parent
The master GameEngine frame work. |
Constructor Summary | |
---|---|
GameObject(GameEngine parent)
Creates new GameObject with specified GameEngine
as the master engine. |
Method Summary | |
---|---|
boolean |
checkPosMouse(int x1,
int y1,
int x2,
int y2)
Returns whether the mouse pointer is inside specified screen boundary. |
boolean |
checkPosMouse(Sprite sprite,
boolean pixelCheck)
Returns whether the mouse pointer is inside specified sprite boundary. |
boolean |
click()
Effectively equivalent to the call bsInput.isMousePressed(java.awt.event.MouseEvent.BUTTON1). |
void |
drawFPS(Graphics2D g,
int x,
int y)
Draws game frame-per-second (FPS) to specified location. |
void |
finish()
End this game, and back to game object chooser. |
int |
getCurrentFPS()
Effectively equivalent to the call bsTimer.getCurrentFPS(). |
int |
getFPS()
Effectively equivalent to the call BaseTimer.getFPS(). |
int |
getHeight()
Effectively equivalent to the call bsGraphics.getSize().height. |
BufferedImage |
getImage(String imagefile)
Effectively equivalent to the call bsLoader.getImage(String). |
BufferedImage |
getImage(String imagefile,
boolean useMask)
Effectively equivalent to the call bsLoader.getImage(String, boolean). |
BufferedImage[] |
getImages(String imagefile,
int col,
int row)
Effectively equivalent to the call bsLoader.getImages(String, int, int). |
BufferedImage[] |
getImages(String imagefile,
int col,
int row,
boolean useMask)
Effectively equivalent to the call bsLoader.getImages(String, int, int, boolean). |
BufferedImage[] |
getImages(String imagefile,
int col,
int row,
boolean useMask,
int start,
int end)
Returns stripped images with cropped sequence. |
BufferedImage[] |
getImages(String imagefile,
int col,
int row,
boolean useMask,
String sequence,
int digit)
Returns stripped images with specified sequence. |
BufferedImage[] |
getImages(String imagefile,
int col,
int row,
int start,
int end)
Same as getImages(imagefile, col, row, useMask, start, end) with mask color is turned on by default. |
BufferedImage[] |
getImages(String imagefile,
int col,
int row,
String sequence,
int digit)
Same as getImages(imagefile, col, row, useMask, sequence, digit) with mask color is turned on by default. |
int |
getMouseX()
Effectively equivalent to the call bsInput.getMouseX(). |
int |
getMouseY()
Effectively equivalent to the call bsInput.getMouseY(). |
int |
getRandom(int low,
int hi)
Effectively equivalent to the call Utility.getRandom(int, int) |
int |
getWidth()
Effectively equivalent to the call bsGraphics.getSize().width. |
void |
hideCursor()
Effectively equivalent to the call bsInput.setMouseVisible(false). |
abstract void |
initResources()
All game resources initialization, everything that usually goes to constructor should be put in here. |
boolean |
keyDown(int keyCode)
Effectively equivalent to the call bsInput.isKeyDown(int). |
boolean |
keyPressed(int keyCode)
Effectively equivalent to the call bsInput.isKeyPressed(int). |
int |
playMusic(String audiofile)
Effectively equivalent to the call bsMusic.play(String). |
int |
playSound(String audiofile)
Effectively equivalent to the call bsSound.play(String). |
abstract void |
render(Graphics2D g)
Renders game to the screen. |
boolean |
rightClick()
Effectively equivalent to the call bsInput.isMousePressed(java.awt.event.MouseEvent.BUTTON3). |
void |
setFPS(int fps)
Effectively equivalent to the call bsTimer.setFPS(int). |
void |
setMaskColor(Color c)
Effectively equivalent to the call bsLoader.setMaskColor(java.awt.Color). |
void |
showCursor()
Effectively equivalent to the call bsInput.setMouseVisible(true). |
void |
start()
Starts the game main loop, this method will not return until the game is finished playing/running. |
BufferedImage |
takeScreenShot()
Returns a new created buffered image which the current game state is rendered into it. |
void |
takeScreenShot(File f)
Captures current game screen into specified file. |
abstract void |
update(long elapsedTime)
Updates game variables. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public final GameEngine parent
GameEngine
frame work.
public BaseGraphics bsGraphics
public BaseIO bsIO
public BaseLoader bsLoader
public BaseInput bsInput
public BaseTimer bsTimer
public BaseAudio bsMusic
public BaseAudio bsSound
public GameFontManager fontManager
Constructor Detail |
---|
public GameObject(GameEngine parent)
GameObject
with specified GameEngine
as the master engine.
Method Detail |
---|
public final void start()
public void finish()
GameEngine.nextGameID
,
GameEngine.nextGame
public abstract void initResources()
This method is called only once for every newly created
GameObject
class.
getImage(String)
,
getImages(String, int, int)
,
playMusic(String)
,
setMaskColor(Color)
,
com.golden.gamedev.object
public abstract void update(long elapsedTime)
keyDown(int)
,
keyPressed(int)
public abstract void render(Graphics2D g)
g
- backbuffer graphics contextpublic int getRandom(int low, int hi)
public int getWidth()
public int getHeight()
public BufferedImage takeScreenShot()
public void takeScreenShot(File f)
takeScreenShot()
public int playMusic(String audiofile)
BaseAudio.setBaseRenderer(com.golden.gamedev.engine.BaseAudioRenderer)
,
com.golden.gamedev.engine.audio
public int playSound(String audiofile)
BaseAudio.setBaseRenderer(com.golden.gamedev.engine.BaseAudioRenderer)
,
com.golden.gamedev.engine.audio
public void setFPS(int fps)
public int getCurrentFPS()
public int getFPS()
public void drawFPS(Graphics2D g, int x, int y)
public int getMouseX()
public int getMouseY()
public boolean checkPosMouse(int x1, int y1, int x2, int y2)
public boolean checkPosMouse(Sprite sprite, boolean pixelCheck)
sprite
- sprite to check its intersection with mouse pointerpixelCheck
- true, checking the sprite image with pixel precisionpublic boolean click()
public boolean rightClick()
public boolean keyDown(int keyCode)
public boolean keyPressed(int keyCode)
public void hideCursor()
public void showCursor()
public void setMaskColor(Color c)
public BufferedImage getImage(String imagefile, boolean useMask)
public BufferedImage getImage(String imagefile)
public BufferedImage[] getImages(String imagefile, int col, int row, boolean useMask)
public BufferedImage[] getImages(String imagefile, int col, int row)
public BufferedImage[] getImages(String imagefile, int col, int row, boolean useMask, String sequence, int digit)
First the image is stripped by column and row, and then the images is arranged with specified sequence order. The images then stored into cache (bsLoader) with key as followed: the image file + sequence + digit.
For example:
// we want the images sequence is as followed String sequence = "020120"; BufferedImage[] image = getImages("imagestrip.png", 3, 1, true, sequence, 1); // this is plain same like above code except we use 2 digits here // 2 digits is used for image strip larger than 10 String sequence = "000200010200"; BufferedImage[] image = getImages("imagestrip.png", 20, 1, true, sequence, 1);Notice that the first image is start from 0 (zero).
This is used to make custom animation (012321).
public BufferedImage[] getImages(String imagefile, int col, int row, String sequence, int digit)
public BufferedImage[] getImages(String imagefile, int col, int row, boolean useMask, int start, int end)
First the image is stripped by column and row, and then the images is arranged with specified series sequence order. The images then stored into cache (bsLoader with key as followed: start sequence + the image file + end sequence.
For example:
int start = 2, end = 4; BufferedImage[] image = getImages("imagestrip.png", 6, 1, true, start, end);Notice that the first image is start from 0 (zero).
public BufferedImage[] getImages(String imagefile, int col, int row, int start, int end)
|
GTGE API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |