0 votes
by (170 points)
Good morning, i am new at Twine, and sorry for my english.

In the story I am writing, I would like to insert a timed event: an image that appears and disappears (or that is replaced by another). The reader must click on the link when the image disappears to go on, if the reader misses it lose.
I would therefore like to have an image for a few seconds, disappear for one second and reappear again for a few seconds, cyclically. Is there a way to do it?
Thank you.

2 Answers

+1 vote
by (590 points)
selected by
 
Best answer

In SugarCube, you can do this by combining the repeat and timed macros.  The code below would basically hide the image for 1 second and display it for 5 (shows for 4s, hides for 1s, shows for 1s, then starts over).

<<set _imageVisible to true>>
<span id="img-cycle">[img[a.jpg]]</span>

<<link "Link Text Here">>
	<<if _imageVisible>>
		/* Do something */
	<<else>>
		/* Do something else */
	<</if>>
<</link>>
<<silently>>
	<<repeat 6s>>
		<<timed 4s>>
			<<set _imageVisible to false>>
			<<replace "#img-cycle">><</replace>>
		<<next 1s>>
			<<set _imageVisible to true>>
			<<replace "#img-cycle">>[img[a.jpg]]<</replace>>
		<</timed>>
	<</repeat>>
<</silently>>

 

+1 vote
by (44.7k points)
How to do that depends on what Twine story format you're using (probably either Harlowe or SugarCube).  If you aren't sure which one you're using, you can do "Change Story Format" from the bottom pop-up menu to see which story format is currently selected (Harlowe is the default, but SugarCube is a bit more popular due to its additional features).

You should add the story format you're using to the tags on this question so that people familiar with that story format can help you.
...