Code: Select all
label main_menu:
return
define _confirm_quit = False
init python:
import pygame
class KeyHold(renpy.Displayable):
def __init__(self,**kwargs):
super(KeyHold, self).__init__(**kwargs)
def render(self,w,h,st,at):
global foo
if foo: r = Solid('#0f0').render(100,100,st,at)
else: r = Solid('#f00').render(100,100,st,at)
renpy.redraw(self,0)
return r
def event(self, event, x, y, st):
global foo
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_a:
foo = True
elif event.type == pygame.KEYUP:
if event.key == pygame.K_a:
foo = False
image keycatcher = KeyHold()
label start:
$ foo = False
show keycatcher at truecenter
"press a"
return
Code: Select all
label main_menu:
return
define _confirm_quit = False
init python:
import pygame
class Indicator(renpy.Displayable):
'''
Used in this example only to track the change of a variable in real time.
Draws a red box if the global variable foo == False,
draws a green square, if the global variable foo == True.
'''
def render(self,w,h,st,at):
global foo
if foo: r = Solid('#0f0').render(100,100,st,at)
else: r = Solid('#f00').render(100,100,st,at)
renpy.redraw(self,0)
return r
class KeyCatcher(renpy.Displayable):
'''
When you are on the screen receives events and allows you to respond to them.
'''
def render(self,w,h,st,at):
return Null().render(w,h,st,at)
def event(self, event, x, y, st):
global foo
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_a:
foo = True
elif event.type == pygame.KEYUP:
if event.key == pygame.K_a:
foo = False
screen barsik():
add KeyCatcher()
frame:
align (0.5,0.5)
vbox:
add Indicator()
label "hold a":
align (0.5,0.5)
label start:
$ foo = False
call screen barsik
"end"
return
And viewtopic.php?f=8&t=26961&p=327013&hilit=button#p327339
viewtopic.php?t=68143