Drag n' Drop glitches when calling something animated
Posted: Sun Jul 27, 2014 8:34 pm
I left another report concerning drag n' drop, but I encountered a different issue.
This one seems to come up when something is being dragged and a timer or something using ATL goes off, resulting in the drag (And in many cases the game itself) freezing. The following examples happened on a screen brought using the call command and a game with built distributions (I had a few instances of errors showing up only after building them, mostly regarding blank spaces after the filenames. "background.png " wouldn't show as an error until the distributions were built).
This was the code for the draggable:
It was simple, when added to the dragged function of the draggable, if dropped into a droppable it added +1 to $ var_a (Otherwise, it wouldn't add anything) returning to it's place afterwards.
I tried adding an effect to it when dropped into the droppable, first I used a simple screen
"flash" was an already declared animation that went like:
I added it to the draggable code by using:
At first it works as intended, showing the effect with no problem. However, if the dragged is used afterwards again quickly, the draggable (And sometimes the whole game) freezes and has to be reloaded. I tried moving show_screen just before restart_interaction (Which was needed in the game one way or the other) but the problem remained.
Thinking it was because of the screen's timer, I changed a bit the code of the "flash" image so it went to alpha 0 after the animation ended and then I changed the draggable code to:
I repeated the process of putting ui.add before restart_interaction, but either way, the problem remained.
What's more, I had a keyboard key programmed to use the same animation in the effects screen for testing purposes, if the key was pressed when the object was being dragged, the animation would play and the drag would be frozen in place afterwards (As with the other cases, sometimes freezing the whole game with it).
This one seems to come up when something is being dragged and a timer or something using ATL goes off, resulting in the drag (And in many cases the game itself) freezing. The following examples happened on a screen brought using the call command and a game with built distributions (I had a few instances of errors showing up only after building them, mostly regarding blank spaces after the filenames. "background.png " wouldn't show as an error until the distributions were built).
This was the code for the draggable:
Code: Select all
init python:
def var_a_add(drags, drop):
if not drop:
drags[0].snap(952, 329, delay=0)
return
else:
store.var_a += 1
drags[0].snap(952, 329, delay=0)
renpy.restart_interaction()
return
I tried adding an effect to it when dropped into the droppable, first I used a simple screen
Code: Select all
screen effects:
timer 0.2 action Hide("effects")
add "flash"
Code: Select all
image flash:
add "1.png"
pause 0.1
add "2.png"
pause 0.1
Code: Select all
init python:
def var_a_add(drags, drop):
if not drop:
drags[0].snap(952, 329, delay=0)
return
else:
store.var_a += 1
drags[0].snap(952, 329, delay=0)
renpy.restart_interaction()
renpy.show_screen("effects")
return
Thinking it was because of the screen's timer, I changed a bit the code of the "flash" image so it went to alpha 0 after the animation ended and then I changed the draggable code to:
Code: Select all
init python:
def var_a_add(drags, drop):
if not drop:
drags[0].snap(952, 329, delay=0)
return
else:
store.var_a += 1
drags[0].snap(952, 329, delay=0)
renpy.restart_interaction()
ui.add("flash")
return
What's more, I had a keyboard key programmed to use the same animation in the effects screen for testing purposes, if the key was pressed when the object was being dragged, the animation would play and the drag would be frozen in place afterwards (As with the other cases, sometimes freezing the whole game with it).