-
Notifications
You must be signed in to change notification settings - Fork 32
Frice engine API reference
This is the full API reference of frice engine.
Some classes and interface are private, so they are not shown here.
Do not override the constructor, anything about initialization please put them into "onInit()"!
See README.
Method | Usage |
---|---|
onInit() | Invoked when initializing |
onExit() | Invoked when exiting (NOTE: engine does not perform process termination automatically) |
onRefresh() | Invoked after game window is refreshed, if not paused) |
onClick(OnClickEvent) | Invoked while clicking in game window |
onMouse(OnMouseEvent) | Invoked when a mouse event arrives(moving, pressing, etc) |
onLoseFocus(OnWindowEvent) | Invoked when game window blurs |
onFocus(OnWindowEvent) | Invoke when game window gets focus |
customDraw(Graphics2D) | Override to draw something after everything was drawn. |
Method | Usage |
---|---|
addObject(FObject) | Adds an object to game window |
addObject(Array) | Adds objects to game window |
addObject(List) | Adds objects to game window |
removeObject(FObject) | Removes an object from screen |
removeObject(Array) | Removes objects from screen |
removeObject(List) | Removes objects from screen |
addTimeListener(FTimeListener) | Adds a timer listener. It will be invoked when timeouts. |
addTimeListener(Array) | Add timer listeners. It will be invoked when timeouts. |
addTimeListener(List) | Add timer listeners. It will be invoked when timeouts. |
removeTimeListener(FTimeListener) | Remove a object from timer listeners. |
removeTimeListener(Array) | Remove objects from timer listeners. |
removeTimeListener(List) | Remove objects from timer listeners. |
setBack(FResource) | Sets window background |
setCursor(ImageObject) | Sets the cursor as an ImageObject. You can operate it like any other objects. This will call addObject() by itself. |
setCursor(ImageResource) | Create an ImageObject and invoke the last method |
getScreenCut(): ImageResource | Returns the current screenshot. |
setAutoGC(Boolean) | if true, the engine will remove objects far from the game window. |
setBounds(Int, Int, Int, Int) | Inherited from Frame |
setTitle(String) | Inherited from Frame |
setLoseFocusChangeColor(Boolean) | if true, the game scene color will become darker when lose focus. |
Represents a game object.
Name | Usage |
---|---|
getAnims(): List<(FAnim)> | get the list of anims, you can add and remove animations via this. |
getTargets(): List<(Pair<(FObject, Event)>)> | get a list of pairs, it has an object reference and an event interface. when collision occurs, the interface will be called. |
addForce(Double, Double) | add a force to this object(actually you added an accelerate anim to it). It's force, and you had better set the mass first. |
setMass(Double) | set the mass. It's safe, if you set an unsafe value, it will fuck the value automatically. 😂 |
see Demo1.java in the demo repo.
Name: Type | Usage |
---|---|
id: Int | Unique ID |
x: Int | Location x |
y: Int | Location y |
anims: ArrayList | Animation list of this object. Engine will play them if game is not paused. |
targets: ArrayList<Pair<FObject, OnCollideEvent>> | Param FObject is the target object, OnCollideEvent is a lambda which will be called when owner collides the target object. |
see Demo1.java in the demo repo.
org.frice.game.obj.FObject
Param | Usage |
---|---|
res: ImageResource | image resource that will display on game scene |
see Demo7.java in the demo repo.
org.frice.game.obj.FObject
Param | Usage |
---|---|
res: ColorResource | Color of this object. |
shape: FShape | Shape of this object |
A Button.
Param | Usage |
---|---|
colorResource: ColorResource | the color of the button |
text: String | the text on button |
font: Font | the font of the text(doesn't work) |
x: Double | position |
y: Double | position |
width: Double | width |
height: Double | height |
A Button containing an image.
Param | Usage |
---|---|
imageNormal: ImageResource | this will be displayed while button is not pressed. |
imagePressed: ImageResource | the image will be displayed while button is pressed. |
x: Double | position |
y: Double | position |
width: Double | width |
height: Double | height |
An object to display particles.
Name: Type | Usage |
---|---|
image: Image | Image object. |
Name | Usage |
---|---|
fun fromImage(image: BufferedImage) | create an image from bufferedImage |
fun fromFile(file: File) | create an image from file |
fun fromPath(path: String) | create an image from file path |
fun fromWeb(url: String) | create an image from url as string |
fun fromURL(url: URL) | create an image from url |
Param | Usage |
---|---|
file: File file: String |
Image file handler or path to the image file. |
Param | Usage |
---|---|
url: String | URL of the image |
Implements frame animation.
Param | Usage |
---|---|
game: Game | Game context, just pass this in your own Game class |
list: List, Array | List of images |
div: Int | Division time between two images |
Create an image resource from a part of another image.
Method | Usage |
---|---|
setLoop(Boolean) | Set whether the animation should loop. |
Param | Usage |
---|---|
color: Color, Int, String | color |
GREEN, BLUE, GRAY, DARK_GRAY, LIGHT_GRAY, WHITE, RED, BLACK, CYAN, MAGENTA, YELLOW, SHIT_YELLOW, ORANGE, PINK
Method | Alias | Usage |
---|---|---|
v(e: Any?) | verbose | Log a verbose message |
d(e: Any?) | debug | Log a debug message |
i(e: Any?) | info | Log a info message |
w(e: Any?) | warning | Log a warning message |
e(e: Any?) | error | Log an error message |
I'm afraid that I can't doc this FFunction very well for my poor English, so please view its usage in demos.
Param | Usage |
---|---|
time: Int | Interval between two invokes |
Name | Usage |
---|---|
ended() | Returns whether time's up. |
org.frice.game.utils.time.FTimer
Param | Usage |
---|---|
timeUp: () -> Unit, OnTimeEvent | FFunction that will be invoked when time's up(ended() ) |
Operates an xml file for config.
All private. Please use the factory methods getPreference()
.
Name | Usage |
---|---|
getPreference(file: File) getPreference(file: String) |
Creates a instance from a file handler, or path to the file. |
insert(key: String, value: Any?) | Insert a key-value pair into the file |
query(key: String, value: Any) | Query a value by key from the file |
Name | Usage |
---|---|
list() | get a list of pair |
insert(key: String, value: Any?) | Insert a key-value pair into the file |
query(key: String, value: Any) | Query a value by key from the file |
Shows dialogs on screen. Quite simple to use, I think there's no need to write a doc for it.
Constructor needs a context.
See FDialog.kt.
Singleton.
Plays audio. However background music isn't recommended.
Method | Usage |
---|---|
play(file: File) play(file: String) |
Play the wav file specified in arg file . |
getPlayer(file: File) getPlayer(file: String) |
Returns the player thread(for pausing, stopping, etc.) |
The audio player thread.
Method | Usage |
---|---|
start() | Starts playing |
exit() | Stops playing |
Param | Usage |
---|---|
x: Int | Pixels that the owner should move by per second, horizontally. |
y: Int | Pixels that the owner should move by per second, vertically. |
See demos/demo/Demo6.java, demos/demo/Demo7.java
Param | Usage |
---|---|
x: Int | Pixels that the owner's speed should be increased by per second, horizontally. |
y: Int | Pixels that the owner's speed should be increased by per second, vertically. |
Method | Usage |
---|---|
getGravity(g: Double), getGravity() | Returns an AccelerateMove instance which y = g (default 10) and x = 0 |
Defines a user-customized move.
Method | Usage |
---|---|
getXDelta(timeFromBegin: Double): Double | Receives time in seconds elapsed since creation of the owner. Returns pixels that the owner should move by, horizontally. |
getYDelta(timeFromBegin: Double): Double | same as the one above, but vertically. |
Param | Usage |
---|---|
x: Double | How many times bigger that the owner should scale per second, horizontally. |
y: Double | How many times bigger that the owner should scale per second, vertically. |