
Originally Posted by
JimmPooJimmPoo
Hi,
I wrote my first app: nCoin v0.57
nCoin is an App that can toss a coin for something.
so here are my questions:
1.
Is it possible to show an animated img while the coin is "spinning" in the phone?
2.
how to flip the coin through pressing the Joistick?
I just tested a script with an animated .gif and it didn't worked. The image stays still. But, as Bogdan said, you can display them in sequence so it will look like a spin.
To call the function for flipping the coin, you can use canvas.bind, as Bogdan also told you. For example:
Code:
import e32, appuifw, graphics
import key_codes
path = 'E:\\Python\\comeback.gif'
img = graphics.Image.open(path)
def coin_flip():
# handle the flip here ...
def handle_redraw(rect):
canvas.blit(img)
canvas = appuifw.Canvas(event_callback = None, redraw_callback = handle_redraw)
appuifw.app.body = canvas
appuifw.app.body = 'full'
canvas.bind(key_codes.EKeySelect, coin_flip)
app_lock = e32.Ao_lock()
app_lock.wait()
Hope it helps,
Rafael.