Games: reference¶
GENERATED by
tools/game/gen_docs.pyfromschema/components.jsonand the script translator: do not edit. Engine 1.0.0.
The guide is Your first game. Everything here is written in game/main.py, which the build reads and never runs.
Contents¶
- Components
- Actions (for
OnTap,OnCollide,Timer,Lifetime,when(...),on_back=) - Scripts: what a
class X(Script)can use - Errors: every code
Components¶
Sprite¶
Sprite(image)
An image (or a region/frame of an atlas). One texel = one world unit; the pivot is the point at the entity's position.
| Parameter | Type | Default | |
|---|---|---|---|
image |
image | required | assets.image(...) or assets.atlas(...) |
frame |
frame | - | with an atlas: the frame name (file name without extension) or index |
region |
rect | - | [x, y, w, h] in texels |
pivot |
pair | (0.5, 0.5) | |
tint |
color | '#ffffff' | |
alpha |
number | 1 | |
layer |
int | 0 | |
order |
int | 0 | |
filter |
enum (linear, nearest) | 'linear' | nearest for pixel art |
flip_x |
bool | False | |
flip_y |
bool | False |
Canvas¶
Canvas(width, height)
Pixels the game paints while it runs. Scripts set and read any pixel and draw lines, rectangles, circles, fills and stamps of images (self.canvas.set(x, y, "#ff0000")); with brush= the player paints with a finger. One pixel is one world unit; the pivot is the point at the entity's position.
| Parameter | Type | Default | |
|---|---|---|---|
width |
int | 64 | in pixels; with image= and no width, the image's |
height |
int | 64 | in pixels; with image= and no height, the image's |
color |
color | '#00000000' | what it starts filled with (see-through) |
image |
image | - | a PNG it starts from: assets.image(...), or a frame of a sheet or an atlas |
frame |
frame | - | with a sheet or an atlas: the frame it starts from |
pivot |
pair | (0.5, 0.5) | |
alpha |
number | 1 | |
layer |
int | 0 | |
order |
int | 0 | |
filter |
enum (nearest, linear) | 'nearest' | nearest keeps each pixel a sharp square when drawn bigger |
brush |
color | - | the colour the player paints with a finger (none: the player does not paint) |
brush_size |
int | 1 | how wide the brush is, in pixels |
Shape¶
Shape()
A rectangle or a circle, filled or outlined.
| Parameter | Type | Default | |
|---|---|---|---|
shape |
enum (rect, circle) | 'rect' | |
size |
pair | (10, 10) | rect: (width, height) |
radius |
number | 5 | circle |
pivot |
pair | (0.5, 0.5) | |
color |
color | '#ffffff' | |
alpha |
number | 1 | |
filled |
bool | True | |
stroke |
number | 1 | |
layer |
int | 0 | |
order |
int | 0 |
Text¶
Text(text)
Text; the entity's position is the baseline of the first line at the alignment point. Colours inside: "Won [c=#ffd84a]50[/c] coins".
| Parameter | Type | Default | |
|---|---|---|---|
text |
text | required | a text, or t("key") from the app's translations() |
size |
number | 16 | |
color |
color | '#ffffff' | |
alpha |
number | 1 | |
align |
enum (left, center, right) | 'left' | |
layer |
int | 0 | |
order |
int | 0 | |
font |
font | - | assets.font(...); by default the game's font, or the system's |
max_width |
number | 0 | lines are broken to fit this width; 0: only at \n |
line_spacing |
number | 1 | times the font's distance between lines |
max_lines |
int | 0 | lines per page (text.page, text.pages); 0: one page |
Panel¶
Panel(image)
A box of any size: an image cut in nine (border: the size of its corners), or a plain colour with a line. modal: a press anywhere stops here, so nothing below an open menu can be tapped.
| Parameter | Type | Default | |
|---|---|---|---|
image |
image | - | |
size |
pair | (100, 100) | |
border |
int | 8 | |
pivot |
pair | (0.5, 0.5) | |
tint |
color | '#ffffff' | |
color |
color | '#20242c' | without an image |
line |
color | '#e8e8e8' | without an image |
alpha |
number | 1 | |
layer |
int | 0 | |
order |
int | 0 | |
filter |
enum (linear, nearest) | 'nearest' | |
modal |
bool | False |
Button¶
Button(label, *actions)
A button with a label. A click is a finger going down and coming up on it (sliding off cancels). It plays its sound, runs its actions, and scripts see self.button.clicked.
| Parameter | Type | Default | |
|---|---|---|---|
label |
text | required | |
actions |
actions | () | |
size |
pair | (100, 32) | |
pivot |
pair | (0.5, 0.5) | |
border |
int | 8 | |
image |
image | - | cut in nine, like a Panel |
pressed |
image | - | |
disabled |
image | - | |
color |
color | '#3a4252' | without an image |
pressed_color |
color | '#596479' | |
disabled_color |
color | '#2a2e36' | |
line |
color | '#e8e8e8' | |
alpha |
number | 1 | |
layer |
int | 0 | |
order |
int | 0 | |
filter |
enum (linear, nearest) | 'nearest' | |
enabled |
bool | True | |
sound |
sound | - | |
font |
font | - | |
text_size |
number | 14 | |
text_color |
color | '#ffffff' |
Bar¶
Bar(value)
A bar filling from the left that glides to a new value (life bars), changing colour at two thresholds. Scripts: self.bar.value, .max, .shown, .moving.
| Parameter | Type | Default | |
|---|---|---|---|
value |
number | 1 | |
max |
number | 1 | |
size |
pair | (60, 6) | |
pivot |
pair | (0, 0.5) | |
color |
color | '#58c858' | |
mid_color |
color | '#e8c840' | |
low_color |
color | '#d84840' | |
back |
color | '#303030' | |
mid_at |
number | 0.5 | |
low_at |
number | 0.2 | |
speed |
number | 0.5 | fractions of max per second; 0: at once |
alpha |
number | 1 | |
layer |
int | 0 | |
order |
int | 0 |
ScrollList¶
ScrollList(row)
A long list, or a grid with columns > 1. Only the rows that fit exist, used again as it scrolls; a Script on the same entity fills them in on_row(self, row, index). Drag to scroll. A row is an entity at the centre of its cell. On a ui entity.
| Parameter | Type | Default | |
|---|---|---|---|
row |
entity | required | |
count |
int | 0 | |
size |
pair | (200, 200) | |
item_size |
pair | (200, 32) | |
columns |
int | 1 | |
gap |
number | 0 | |
pivot |
pair | (0, 0) | |
bar_color |
color | '#ffffff80' | |
layer |
int | 0 | |
order |
int | 0 |
Tabs¶
Tabs(labels)
A row of tabs, one always selected. Scripts: self.tabs.selected, self.tabs.changed. Its origin is its top-left corner.
| Parameter | Type | Default | |
|---|---|---|---|
labels |
strings | required | |
selected |
int | 0 | |
size |
pair | (240, 28) | |
image |
image | - | |
selected_image |
image | - | |
border |
int | 8 | |
color |
color | '#2a2e36' | |
selected_color |
color | '#596479' | |
line |
color | '#e8e8e8' | |
text_color |
color | '#ffffff' | |
font |
font | - | |
text_size |
number | 14 | |
layer |
int | 0 | |
order |
int | 0 | |
sound |
sound | - |
Toggle¶
Toggle(label)
A box that is on or off, with a label. Scripts: self.toggle.value, self.toggle.changed.
| Parameter | Type | Default | |
|---|---|---|---|
label |
text | required | |
value |
bool | False | |
size |
pair | (120, 24) | |
pivot |
pair | (0, 0.5) | |
image |
image | - | |
on_image |
image | - | |
border |
int | 4 | |
color |
color | '#3a4252' | |
on_color |
color | '#58c858' | |
line |
color | '#e8e8e8' | |
font |
font | - | |
text_size |
number | 14 | |
text_color |
color | '#ffffff' | |
layer |
int | 0 | |
order |
int | 0 | |
filter |
enum (linear, nearest) | 'nearest' | |
sound |
sound | - |
Slider¶
Slider(value)
A value set with a finger along a track. Scripts: self.slider.value, self.slider.changed.
| Parameter | Type | Default | |
|---|---|---|---|
value |
number | 0 | |
min |
number | 0 | |
max |
number | 1 | |
step |
number | 0 | values go in these steps; 0: any |
size |
pair | (160, 24) | |
pivot |
pair | (0, 0.5) | |
color |
color | '#58c858' | |
back |
color | '#303030' | |
thumb |
color | '#e8e8e8' | |
image |
image | - | the thumb, instead of a colour |
layer |
int | 0 | |
order |
int | 0 | |
filter |
enum (linear, nearest) | 'nearest' |
Keyboard¶
Keyboard()
A keyboard drawn in the game. Letters are capital until the first one is typed. Scripts: self.keyboard.text, .changed, .done. Its origin is its top-left corner.
| Parameter | Type | Default | |
|---|---|---|---|
rows |
strings | () | the letters of each row; by default QWERTY |
text |
string | '' | |
max_length |
int | 12 | |
size |
pair | (260, 150) | |
gap |
number | 2 | |
ok_label |
string | 'OK' | |
shift_label |
string | 'Aa' | |
delete_label |
string | '<' | |
image |
image | - | |
border |
int | 4 | |
color |
color | '#3a4252' | |
line |
color | '#e8e8e8' | |
text_color |
color | '#ffffff' | |
font |
font | - | |
text_size |
number | 14 | |
layer |
int | 0 | |
order |
int | 0 | |
sound |
sound | - |
Spin¶
Spin(speed)
Turns the entity at a constant speed (degrees per second).
| Parameter | Type | Default | |
|---|---|---|---|
speed |
number | 90 |
Mover¶
Mover(velocity)
Moves at a constant velocity (units per second); with bounce, turns back at the edges.
| Parameter | Type | Default | |
|---|---|---|---|
velocity |
pair | (0, 0) | |
bounce |
bool | False |
OnTap¶
OnTap(*actions)
Runs actions, in order, when the entity is tapped (area: its Sprite/Shape, or radius/size).
| Parameter | Type | Default | |
|---|---|---|---|
actions |
actions | () | |
radius |
number | 0 | |
size |
pair | (0, 0) |
Collider¶
Collider()
The shape for the physics (axis-aligned box or circle). solid: bodies cannot pass; trigger: only reports contacts.
| Parameter | Type | Default | |
|---|---|---|---|
shape |
enum (box, circle) | 'box' | |
size |
pair | (10, 10) | |
radius |
number | 5 | |
offset |
pair | (0, 0) | |
solid |
bool | False | |
trigger |
bool | False |
Body¶
Body()
Arcade physics: velocity, gravity (units/s2, down), blocked by solid tiles and solid colliders.
| Parameter | Type | Default | |
|---|---|---|---|
velocity |
pair | (0, 0) | |
gravity |
number | 0 | |
max_fall |
number | 1200 | |
bounce |
number | 0 | |
collide |
bool | True |
OnCollide¶
OnCollide(tag, *actions)
Runs actions when this entity starts touching another with the tag, from a side (top = the other came from above).
| Parameter | Type | Default | |
|---|---|---|---|
tag |
string | '' | |
actions |
actions | () | |
side |
enum (any, top, bottom, sides) | 'any' |
PlatformerController¶
PlatformerController()
Run and jump (needs Body with gravity and a Collider). Keys: arrows/A/D, space/up/W, or TouchButton left/right/jump.
| Parameter | Type | Default | |
|---|---|---|---|
speed |
number | 120 | |
jump |
number | 330 | |
coyote |
number | 0.1 | |
buffer |
number | 0.12 |
TopDownController¶
TopDownController()
Moves towards the finger while it is down, else with the arrow keys; axis x / y / both.
| Parameter | Type | Default | |
|---|---|---|---|
speed |
number | 200 | |
axis |
enum (both, x, y) | 'both' | |
pointer |
bool | True | |
clamp |
bool | True | |
margin |
number | 16 |
Follow¶
Follow()
Moves towards the entity called target, or the nearest with tag.
| Parameter | Type | Default | |
|---|---|---|---|
target |
string | '' | |
tag |
string | '' | |
speed |
number | 80 | |
stop |
number | 4 |
Patrol¶
Patrol()
Walks left and right; turns at walls, ledges (edges) or after distance (needs Body).
| Parameter | Type | Default | |
|---|---|---|---|
speed |
number | 60 | |
distance |
number | 0 | |
edges |
bool | True | |
direction |
int | 1 |
Spawner¶
Spawner(entity)
Makes copies of an entity every few seconds, at the spawner (+ offset) or in an area (x, y, w, h).
| Parameter | Type | Default | |
|---|---|---|---|
entity |
entity | required | |
every |
number | 1 | |
jitter |
number | 0 | |
delay |
number | 0 | |
offset |
pair | (0, 0) | |
area |
box | - | |
limit |
int | 0 | |
total |
int | 0 |
Lifetime¶
Lifetime(seconds, *actions)
Destroys the entity after seconds (running the actions first).
| Parameter | Type | Default | |
|---|---|---|---|
seconds |
number | 1 | |
actions |
actions | () |
Timer¶
Timer(every, *actions)
Runs actions every few seconds (repeat=False: once).
| Parameter | Type | Default | |
|---|---|---|---|
every |
number | 1 | |
actions |
actions | () | |
delay |
number | 0 | |
repeat |
bool | True |
Tween¶
Tween(property, to, duration)
Animates x, y, rotation, scale or alpha to a value.
| Parameter | Type | Default | |
|---|---|---|---|
property |
enum (x, y, rotation, scale, alpha) | 'scale' | |
to |
number | 1 | |
duration |
number | 1 | |
delay |
number | 0 | |
ease |
enum (linear, in, out, inout, sine, back) | 'inout' | |
mode |
enum (once, loop, pingpong) | 'pingpong' |
Animator¶
Animator(animations)
Frame animations of the entity's Sprite: {"run": {"frames": [0, 1, 2], "fps": 10}}. auto: plays the PlatformerController state (idle, run, jump, fall).
| Parameter | Type | Default | |
|---|---|---|---|
animations |
animations | required | |
play |
string | '' | |
auto |
bool | True |
Emitter¶
Emitter()
Particles: burst at start, then rate per second for duration (0: forever). angle in degrees (90 = down).
| Parameter | Type | Default | |
|---|---|---|---|
rate |
number | 0 | |
burst |
int | 0 | |
duration |
number | 0 | |
lifetime |
pair | (0.4, 0.8) | |
speed |
pair | (40, 120) | |
angle |
pair | (0, 360) | |
gravity |
number | 0 | |
size |
pair | (6, 1) | |
color |
color | '#ffffff' | |
color_end |
color | - | |
layer |
int | 5 | |
image |
image | - |
Tilemap¶
Tilemap(map)
A map made in Tiled (assets.tilemap). solid: the tile layers that block bodies. objects: an entity for each Tiled object name/class.
| Parameter | Type | Default | |
|---|---|---|---|
map |
tilemap | required | |
solid |
strings | - | layer names (default: layers with the Tiled property solid=true, or named "solid") |
objects |
objects | - | |
layer |
int | -10 | |
filter |
enum (linear, nearest) | 'nearest' |
Billboard¶
Billboard(image)
2.5D: a sprite standing on the ground, turned to the camera. image: a sheet (assets.sheet) with one row per direction (1, 4: down, left, up, right; 8: with the diagonals in between) and one column per walking frame.
| Parameter | Type | Default | |
|---|---|---|---|
image |
image | required | assets.sheet(...) or assets.image(...) |
directions |
int | 1 | 1, 4 or 8 |
fps |
number | 8 | walking frames per second |
facing |
number | 0 | degrees on the ground: 0 down, 90 right, 180 up, 270 left |
auto_facing |
bool | True | turn to where it walks |
stand |
bool | True | follow the heights of the scene's Tilemap |
tint |
color | '#ffffff' | |
alpha |
number | 1 | |
filter |
enum (linear, nearest) | 'nearest' | |
pivot |
pair | (0.5, 1) | (0.5, 1): the middle of the feet |
Block¶
Block(size, height)
2.5D: a box on the ground (houses, walls, crates): size (width, depth) around the entity, height up. top/side: an image stretched on the face, or a colour.
| Parameter | Type | Default | |
|---|---|---|---|
size |
pair | (16, 16) | |
height |
number | 16 | |
top |
image | - | |
side |
image | - | |
top_color |
color | '#ffffff' | |
side_color |
color | '#ffffff' | |
filter |
enum (linear, nearest) | 'nearest' |
Plane¶
Plane(image)
2.5D: one picture as a quad, standing (signs, fences) or flat on the ground (rugs, shadows); cross: two standing quads at right angles (a cheap tree).
| Parameter | Type | Default | |
|---|---|---|---|
image |
image | - | |
color |
color | '#ffffff' | |
alpha |
number | 1 | |
size |
pair | (16, 16) | |
flat |
bool | False | |
cross |
bool | False | |
filter |
enum (linear, nearest) | 'nearest' |
GridController¶
GridController()
Walks one tile at a time (arrows/WASD, TouchButton keys, or tapping a cell). A short press in a new direction only turns. Blocked by solid tiles and by entities with the tags in block: such an entity fills its cell, and one with a Block (a house) every cell the Block is on.
| Parameter | Type | Default | |
|---|---|---|---|
tile |
number | 16 | the size of a cell, world units |
speed |
number | 4 | cells per second |
tap |
bool | True | walk to a tapped cell (set False with on-screen buttons) |
block |
strings | (solid) | tags of the entities it cannot walk through |
TouchButton¶
TouchButton(key)
An on-screen button (ui=True entity with a Shape/Sprite) that holds a key: left, right, jump, space...
| Parameter | Type | Default | |
|---|---|---|---|
key |
string | required | |
radius |
number | 0 | |
size |
pair | (0, 0) |
Actions¶
sound¶
sound(sound, volume)
Plays a sound.
| Parameter | Type | Default | |
|---|---|---|---|
sound |
sound | required | |
volume |
number | 1 |
destroy¶
destroy(target)
Removes an entity: this one, or target="other" (the one touched).
| Parameter | Type | Default | |
|---|---|---|---|
target |
enum (self, other) | 'self' |
var_add¶
var_add(var, amount)
Adds to a game variable (score, lives...): texts show it as {name}.
| Parameter | Type | Default | |
|---|---|---|---|
var |
string | required | |
amount |
number | 1 |
var_set¶
var_set(var, value)
Sets a game variable.
| Parameter | Type | Default | |
|---|---|---|---|
var |
string | required | |
value |
number | required |
spawn¶
spawn(entity)
Makes a copy of an entity at self / other (+ offset), or at the world point offset (at="world").
| Parameter | Type | Default | |
|---|---|---|---|
entity |
entity | required | |
offset |
pair | (0, 0) | |
at |
enum (self, other, world) | 'self' |
goto_scene¶
goto_scene(scene)
Changes scene (variables carry over). at: entities tagged "arrives" appear at the entity or Tiled object of that name. fade: seconds to black and back.
| Parameter | Type | Default | |
|---|---|---|---|
scene |
string | required | |
at |
string | - | |
fade |
number | 0 |
impulse¶
impulse(velocity, target)
Sets a Body's velocity (keep_x: only vertical), e.g. bounce off a stomped enemy.
| Parameter | Type | Default | |
|---|---|---|---|
velocity |
pair | required | |
target |
enum (self, other) | 'self' | |
keep_x |
bool | False |
respawn¶
respawn(target)
Puts an entity back where it entered the scene, stopped.
| Parameter | Type | Default | |
|---|---|---|---|
target |
enum (self, other) | 'self' |
deflect¶
deflect(angle, target)
Sends a Body away from what it touched, turned by where it touched it: straight from the middle, up to angle degrees at the ends. Its speed stays. A ball on a paddle: OnCollide("paddle", deflect()) on the ball, and the player aims.
| Parameter | Type | Default | |
|---|---|---|---|
angle |
number | 60 | degrees from straight, at the very end of what it touched |
target |
enum (self, other) | 'self' |
exit_game¶
exit_game(result)
Ends the game; the ApkPy screen gets {"action": "exit", "result": result}.
| Parameter | Type | Default | |
|---|---|---|---|
result |
dict | {} |
open_app¶
open_app(screen, data)
Opens an ApkPy screen; the game is suspended (game_resume continues it).
| Parameter | Type | Default | |
|---|---|---|---|
screen |
string | required | |
data |
dict | {} |
store_add¶
store_add(key, amount)
Adds to a number in the store shared with the app (game_get); var="score" adds that variable's value.
| Parameter | Type | Default | |
|---|---|---|---|
key |
string | required | |
amount |
number | 1 | |
var |
string | - |
store_set¶
store_set(key, value)
Sets a text in the store shared with the app.
| Parameter | Type | Default | |
|---|---|---|---|
key |
string | required | |
value |
string | required |
only_if¶
only_if(condition, *actions)
Runs the actions after it only when the condition holds now, as in when(...): "keys >= 1" (a game variable) or "count(coin) == 0" (the entities with a tag). A door that needs a key, a shop that needs coins.
| Parameter | Type | Default | |
|---|---|---|---|
condition |
condition | required | name op number, or count(tag) op number |
actions |
actions | () |
Scripts¶
A class Name(Script) in game/main.py is translated to Java by the build (never run). Fields are annotated (speed: float = 200.0) and can be set where the script is used (Ship(speed=240.0)). Methods: on_start(self), update(self, dt: float), on_collide(self, other: Entity, side: str), on_tap(self), on_destroy(self), and your own (annotated).
Types: Animator, Bar, Billboard, Body, Button, Canvas, Entity, GridController, Image, Keyboard, Panel, Prefab, Props, ScrollList, Shape, Slider, Sound, Sprite, Tabs, Text, Toggle, bool, float, int, str, void, and the game's own @dataclass classes.
Python built-ins: len, abs, min, max, round, int, float, str, range, print; lists (append, pop, insert, remove, clear, [i], [-1], len), dicts with str keys ([k], get, keys, values, pop, clear, in, for k in d, in insertion order), f-strings, math and random (seeded: the same game every run).
Many files¶
Every .py file under game/ is a module: from game.x.y import name or import game.x.y as y. A module holds imports, constants, module state (STATE = Store(): a list, a dict or a data class, reset for each new game and part of the state hash), plain functions, @dataclass classes and Script classes; the declarations stay in game/main.py. From dataclasses: dataclass, field(default_factory=...) and replace(obj, field=value). Plain functions and data class methods can use math and random, not game, scene, input or audio.
Data, JSON and saves¶
SPECIES = table("data/species", Species)at the top of a module: the rows ofdata/species.json(a list) ordata/species/*.json(a row per file), checked at build time against the@dataclass(which needsid: str).SPECIES.get(id),SPECIES.has(id),SPECIES.all(),len(SPECIES),for s in SPECIES,id in SPECIES. A fieldRef[Move](orlist[Ref[Move]]...) holds ids of the Move table, checked too. Treat rows as read-only.to_json(value)andfrom_json(text, Type): a@dataclass(with lists, dicts and other data classes inside) to JSON text and back, the same text as CPython'sjson.dumps(..., separators=(",", ":")). Unknown keys are ignored; missing ones take the default.saves.write(slot, text),saves.read(slot)(Nonewhen empty),saves.exists(slot),saves.delete(slot), in Script methods. Writes are atomic; a read is recorded in the journal, so a game brought back plays with the text it read.- Tiled: an object's custom properties are
self.props.get_str(key)/get_int/get_float/get_bool/has; a tile's custom properties arescene.tile_tag(x, y, key)("" when no tile there has it; hidden layers count).
Properties¶
| On | Name | Type | |
|---|---|---|---|
Entity (and self) |
x |
float | read and write |
Entity (and self) |
y |
float | read and write |
Entity (and self) |
rotation |
float | read and write |
Entity (and self) |
scale |
float | read and write |
Entity (and self) |
name |
str | read |
Entity (and self) |
active |
bool | read and write |
Entity (and self) |
elevation |
float | read and write |
Entity (and self) |
props |
Props | read |
Entity (and self) |
shape |
Shape | read |
Entity (and self) |
panel |
Panel | read |
Entity (and self) |
button |
Button | read |
Entity (and self) |
bar |
Bar | read |
Entity (and self) |
list |
ScrollList | read |
Entity (and self) |
tabs |
Tabs | read |
Entity (and self) |
toggle |
Toggle | read |
Entity (and self) |
slider |
Slider | read |
Entity (and self) |
keyboard |
Keyboard | read |
Entity (and self) |
billboard |
Billboard | read |
Entity (and self) |
grid |
GridController | read |
Entity (and self) |
body |
Body | read |
Entity (and self) |
sprite |
Sprite | read |
Entity (and self) |
text |
Text | read |
Entity (and self) |
animator |
Animator | read |
Entity (and self) |
canvas |
Canvas | read |
Body |
vx |
float | read and write |
Body |
vy |
float | read and write |
Body |
gravity |
float | read and write |
Body |
on_floor |
bool | read |
Body |
on_ceiling |
bool | read |
Body |
on_wall |
bool | read |
Sprite |
flip_x |
bool | read and write |
Sprite |
flip_y |
bool | read and write |
Sprite |
alpha |
float | read and write |
Sprite |
visible |
bool | read and write |
Text |
text |
str | read and write |
Text |
alpha |
float | read and write |
Text |
visible |
bool | read and write |
Text |
size |
float | read and write |
Text |
max_width |
float | read and write |
Text |
page |
int | read and write |
Text |
pages |
int | read |
Text |
lines |
int | read |
Text |
visible_chars |
int | read and write |
Text |
page_chars |
int | read |
Text |
width |
float | read |
Text |
line_height |
float | read |
Animator |
current |
str | read |
Shape |
width |
float | read and write |
Shape |
height |
float | read and write |
Shape |
alpha |
float | read and write |
Shape |
visible |
bool | read and write |
Panel |
width |
float | read and write |
Panel |
height |
float | read and write |
Panel |
alpha |
float | read and write |
Panel |
visible |
bool | read and write |
Panel |
modal |
bool | read and write |
Button |
label |
str | read and write |
Button |
enabled |
bool | read and write |
Button |
visible |
bool | read and write |
Button |
alpha |
float | read and write |
Button |
clicked |
bool | read |
Button |
text |
Text | read |
ScrollList |
count |
int | read and write |
ScrollList |
scroll |
float | read and write |
ScrollList |
max_scroll |
float | read |
ScrollList |
tapped |
int | read |
ScrollList |
visible |
bool | read and write |
Tabs |
selected |
int | read and write |
Tabs |
changed |
bool | read |
Toggle |
value |
bool | read and write |
Toggle |
changed |
bool | read |
Toggle |
enabled |
bool | read and write |
Toggle |
visible |
bool | read and write |
Toggle |
label |
str | read and write |
Slider |
value |
float | read and write |
Slider |
changed |
bool | read |
Slider |
enabled |
bool | read and write |
Slider |
visible |
bool | read and write |
Keyboard |
text |
str | read and write |
Keyboard |
changed |
bool | read |
Keyboard |
done |
bool | read |
Keyboard |
max_length |
int | read and write |
Bar |
value |
float | read and write |
Bar |
max |
float | read and write |
Bar |
shown |
float | read |
Bar |
moving |
bool | read |
Bar |
visible |
bool | read and write |
Billboard |
facing |
float | read and write |
Billboard |
auto_facing |
bool | read and write |
Billboard |
moving |
bool | read |
Billboard |
visible |
bool | read and write |
Canvas |
width |
int | read |
Canvas |
height |
int | read |
Canvas |
visible |
bool | read and write |
Canvas |
alpha |
float | read and write |
Canvas |
brush |
str | read |
Canvas |
brush_size |
int | read and write |
Canvas |
pointer_x |
int | read |
Canvas |
pointer_y |
int | read |
Canvas |
changed |
bool | read |
GridController |
arrivals |
int | read |
GridController |
walking |
bool | read |
GridController |
speed |
float | read and write |
| scene | camera_yaw |
float | read and write |
| scene | camera_pitch |
float | read and write |
| scene | camera_distance |
float | read and write |
| game | width |
float | read |
| game | height |
float | read |
| game | view_width |
float | read |
| game | view_height |
float | read |
| game | arrival |
str | read |
| game | time |
float | read |
| game | steps |
int | read |
| math | pi |
float | read |
| math | e |
float | read |
| math | inf |
float | read |
Functions and methods¶
| Call | Signature |
|---|---|
entity.destroy |
() -> void |
entity.has_tag |
(str) -> bool |
animator.play |
(str) -> void |
text.measure |
(str) -> float |
game.get |
(str) -> float |
game.set |
(str, float) -> void |
game.add |
(str, float) -> void |
game.open_app |
(str) -> void |
game.goto |
(str, str = None, float = 0.0) -> void |
entity.child |
(str) -> Entity |
scrolllist.refresh |
() -> void |
scrolllist.scroll_to |
(int) -> void |
shape.set_color |
(str) -> void |
text.set_color |
(str) -> void |
sprite.set_tint |
(str) -> void |
sprite.set_frame |
(int) -> void |
sprite.set_image |
(str) -> void |
billboard.set_image |
(str) -> void |
gridcontroller.stop |
() -> void |
canvas.set |
(int, int, str) -> void |
canvas.get |
(int, int) -> str |
canvas.fill |
(str) -> void |
canvas.clear |
() -> void |
canvas.rect |
(int, int, int, int, str) -> void |
canvas.line |
(int, int, int, int, str) -> void |
canvas.circle |
(int, int, int, str) -> void |
canvas.flood |
(int, int, str) -> void |
canvas.count |
(str) -> int |
canvas.stamp |
(Image, int, int) -> void |
canvas.set_brush |
(str) -> void |
billboard.set_frame |
(int) -> void |
audio.set_music |
(bool) -> void |
audio.set_sound_volume |
(float) -> void |
scene.pause |
(str) -> void |
scene.resume |
(str) -> void |
scene.is_paused |
(str) -> bool |
input.pointer_on_ui |
() -> bool |
game.store_get |
(str) -> str |
game.store_set |
(str, str) -> void |
game.text |
(str) -> str |
input.axis_x |
() -> float |
input.axis_y |
() -> float |
input.key_down |
(str) -> bool |
input.key_pressed |
(str) -> bool |
input.pointer_down |
() -> bool |
input.pointer_pressed |
() -> bool |
input.pointer_x |
() -> float |
input.pointer_y |
() -> float |
audio.play |
(Sound, float = 1.0) -> void |
scene.spawn |
(Prefab, float, float) -> Entity |
scene.find |
(str) -> Entity? |
scene.count |
(str) -> int |
scene.with_tag |
(str) -> list[Entity] |
scene.tile_tag |
(float, float, str) -> str |
props.get_str |
(str, str = "") -> str |
props.get_int |
(str, int = 0) -> int |
props.get_float |
(str, float = 0.0) -> float |
props.get_bool |
(str, bool = False) -> bool |
props.has |
(str) -> bool |
saves.write |
(str, str) -> void |
saves.read |
(str) -> str? |
saves.exists |
(str) -> bool |
saves.delete |
(str) -> void |
random.random |
() -> float |
random.uniform |
(float, float) -> float |
random.randint |
(int, int) -> int |
math.acos |
(float) -> float |
math.asin |
(float) -> float |
math.atan |
(float) -> float |
math.cos |
(float) -> float |
math.degrees |
(float) -> float |
math.exp |
(float) -> float |
math.fabs |
(float) -> float |
math.log |
(float) -> float |
math.radians |
(float) -> float |
math.sin |
(float) -> float |
math.sqrt |
(float) -> float |
math.tan |
(float) -> float |
math.atan2 |
(float, float) -> float |
math.hypot |
(float, float) -> float |
math.pow |
(float, float) -> float |
Anything else gives a G2xxx error at build time, with the line and how to write it instead (Errors).
Errors¶
Each one names the file and the line, says why, and how to fix it: APKPY G1201 game/main.py:49.
| Codes | Where | |
|---|---|---|
| G10xx | Project and tools | G1001 no game/main.py, G1003 outside a project, G1004 no application_id, G1006 JDK or Android SDK not found, G1007 the engine is missing, G1008 the project folder exists, G1010 a before_build step of apkpy.toml failed |
| G11xx | The app | G1101 writehere.py does not call enable_game() (or has the block of declarations ApkPyGame used to write: apkpy game init mends it); G1102 open_app("x") with no Screen(id="x"); G1103 t("k") with no such key in translations |
| G12xx | Reading game/ |
G1201 not a declaration (for/if...), G1202 value that cannot be read, G1203 unknown name, G1204 unknown parameter, G1205 wrong type, G1206 missing, G1207 import, G1208 classes/build, G1209 Game, G1210 scenes, G1211 asset file, G1212 @prefab, G1214 atlas frame, G1215 atlas too big, G1216 Tiled map (format, tileset, layer), G1217 Tiled object with no entity, G1218 no such module (game/x.py), G1219 import cycle, G1220 not allowed at the top of a module, G1221 font file |
| G13xx | Data tables | G1301 no table file/folder, G1302 not valid JSON, G1303 wrong type, G1304 unknown or missing field, G1305 id used twice, G1306 table setup (id: str, one table per class, Ref to a class with no table), G1307 Ref to an id that does not exist |
| G20xx | Scripts, translated to Java | G2001 statement, G2002 expression, G2003 types, G2004 name, G2005 attribute/method, G2006 missing type, G2007 undeclared field, G2008 truthiness (if x: -> if x != 0:), G2009 arguments, G2010 may be None, G2011 return, G2012 name taken, G2999 a bug of the translator |
| G3100 | A script at run time | An exception in a script, with main.py:line and the error in Python terms (IndexError, ZeroDivisionError...) |
| G30xx | The engine at run time | G3001 format too new, G3002 no such scene, G3005 unknown component (warning), G3021 asset missing, G3022 unreadable image, G3024 nothing to arrive at (game.goto(scene, at)), G3025 a Canvas's image is not a PNG it can read (or the canvas is too big), G3030 a suspended game could not be brought back exactly, G3031 a journal from another engine version, G3040 OpenGL ES did not start (with "auto", the game falls back to the Canvas), G3041 a 2.5D scene drawn with the Canvas, G3998 the desktop runner gave no answer |