Here is the code:
Code: Select all
screen render_secrets():
$ x, y = renpy.get_mouse_pos()
$ print "%s, %s" % (x, y)
if ( mouse pos is some condition):
# show something at x+10, y+20
elif (mouse position is some other condition):
# show something at x+100, y-40
# etc...
screen render_buttons():
imagebutton:
idle "images/card_idle.png"
hover "images/card_hover.png"
action Return("card")
xpos 100
ypos 100
imagebutton:
idle "images/ball_idle.png"
hover "images/ball_hover.png"
action Return("ball")
xpos 100
ypos 500
label doit():
scene bg game
show screen render_buttons()
label render_loop:
# continuously poll for mouse coordinates, and display secrets
show screen render_secrets()
# Allow the player to interact with some displayables
clicked = ui.interact()
$ print clicked
jump render_loop
- Mouse coordinates are not continuously polled. The console does not output a stream of coordinates. It only outputs once, then stops.
- I think ui.interact() is blocking my loop, because I don't see the results of clicked until I click on a displayable that returns an action (the imagebuttons).
Can someone help me with this issue? I essentially want a way to continuously poll the mouse coordinates in the background and then show images based on where the mouse is, while allowing the player to directly interact with my other displayables too.
The secrets are displayed dynamically, and is not always in a static location, which is why I need to constantly get the mouse position.