API reference¶
Generated from the source in apps/micropython/vs2. If you are new to VS2,
read the tutorial first — this section assumes you know
what a layer and a sealed scene are.
Everything lives in two modules:
vs2Scenes, layers, drawables, and the
display,audio,baseandlimitsservices.vs2.controlsThe two controllers and the button constants, designed for
from vs2.controls import *.
Cheat sheet¶
import vs2
from vs2.controls import *
class MyGame(vs2.Scene):
idle_timeout = 30 # seconds; None disables
back_button = True # Y / BACK pops the scene
starfield = False # drifting stars behind the scene
def build(self):
layer = self.layer("world", projection=vs2.TUNNEL)
sprite = layer.sprite("ship.png", x=128, y=0)
pool = layer.sprite_pool("shots.png", count=8, on_empty=vs2.RECYCLE)
ground = layer.tilemap("trench.png", columns=16, rows=16)
score = layer.label("numerals.png", columns=5)
def update(self):
if joy1.held(LEFT): ... # level
if joy1.just_pressed(A): ... # edge
if joy1.just_released(B): ... # edge
def teardown(self):
... # optional
I want to |
Use |
|---|---|
Move something |
|
Animate |
|
Show or hide |
|
Fire a bullet |
|
Retire a bullet |
|
Hit-test |
|
Scroll a map |
|
Edit a map |
|
Show text |
|
Show a score |
|
Text at the top of the disc |
|
Leave a scene |
|
Run something later |
|
Play audio |
|
Keep a high score |
|
Know the display size |
|