I swear I saw this implemented somewhere already but I can't remember what I read and it's driving me mad.
I'd like to structure the passage so that text is revealed as the player clicks or taps the game screen — conceptually, like revealing a paragraph (or whatever arbitrary length of text I want) at a time so the player progresses at their own pace instead of presenting them with a sudden wall of text.
I don't want the passage to change, just the text to gradually appear until the player reaches the section where they're presented with a choice to make — at which point they move on to another passage as normal.
I came across this
https://www.glorioustrainwrecks.com/node/5019
which potentially is what I want (the continue macro) but I know SugarCube 2 has its own continue macro that I think is unrelated to this completely.
I don't want to eliminate or replace text on the screen, just have a div slide into place when the player clicks.
Comments
If you want to change this on a click, you should look at onclick Events.
Not sure why this would be necessary for what you seemingly want to do. You could just do something like:
In stylesheet:
In JavaScript:
Or something like that.
Actually this feels exactly like what I want, although I'm out of the house at the moment so I can't test it just yet.
I made a mistake in that JavaScript. I tested it, but not well enough. Here's a better version:
Sorry for the mix up.
That works perfectly! Question —
Is there something that can be added to that code that on the final "click" when all content is displayed, another div will vanish? IE, I can have a "click to continue" div below the content that then disappears when the sequence is finished and there's nothing further to reveal.
Updated Javascript:
I tweaked the code so that it scrolls down to the top of the new div that was introduced.
This was exactly what I was after and appears to be just fine.