- Picture a large grid of buttons, let's say for example 10x10, 100 buttons.
- There's space enough screen space to show a 5x4 subset.
- It's the basis for a puzzle where the goal is to find the "correct" button.
- I would like to be able to use draggable True on the vpgrid.
- All the buttons should have a hover effect.
The problem:
- Seemingly the only way to have a button respect hover is to assign an action, an alternative action is not enough.
- Indeed without action the alternate setting doesn't even function.
- With an action assigned (even a NullAction()), the mouse events that would cause the drag get swallowed and it's not possible to drag except by grabbing part of the grid between buttons. Which isn't viable without causing massive player confusion.
The code:
Code: Select all
screen the_grid():
default goal = renpy.random.randint(0, 99)
vpgrid:
rows 10
cols 10
draggable True
vpgrid:
rows 10
cols 10
draggable True
for i in xrange(0, 100):
textbutton '[i]':
action NullAction() # commenting this makes it draggable but disables the buttons
alternate If(i == goal, Return('you win'), NullAction())
background ('#fcc' if i == goal else '#ccc')
hover_background '#cfc'
text_color '000'
xysize (config.screen_width / 5, config.screen_height / 4)