How to display an image after a delay such as sys.ms? i understand display.text but dont know how to approach image displaying, thanks for the help in advance guys!
If you have a canvas containing the image, you can change visibility using the show
attribute:
canvas_name.show: "none"
canvas_name.show: "solid"
To show or hide it on a delay, there is a simple way and a more complex way.
The simple way uses the sleep
function. It (mostly) pauses the whole program until it’s finished sleeping. For example, you could use it in a button’s click action:
# Simple, e.g. button script
on click do
card.widgets.canvas_name.show: "none"
sleep[60] # number of frames to sleep for
card.widgets.canvas_name.show: "solid"
end
Complex uses sys.ms
and recursive go[]
functions to allow other things to occur in the meanwhile. You’d need a hidden field to store some extra data. Here the image shows after 1s.
# Complex, with a field called hidden_time
# Button script
on click do
card.widgets.canvas_name.show: "none"
card.widgets.hidden_time.text: sys.ms
go[card]
end
# Card script
on view do
elapsed: sys.ms - card.widgets.hidden_time.text
if elapsed > 1000
card.widgets.canvas_name.show: "solid"
else
go[card]
end
end