Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Could I add a hoverfunction to make words become visible? (Twine 2, Sugarcube 1.0.32 )

Hello everyone,

I am wondering whether it is possible to add a function in my Twine 2 game where individual sentences become visible when the player hovers their mouse cursor over them. The thing I think might be tricky is that I want the text to disappear when the player moves their cursor off the text. My idea is that the player uses their mouse cursor kind of like a flashlight, causing white text to appear against a black background. Also, I want this feature to only last for a couple of passages, not the entire game.

I am using sugarcube 2.0 and hope that there might be some way to make this work, but I need a bit of help as I am not that skilled in working with it.

Many thanks to anyone who might answer this question.

Comments

  • Sorry, I wrote that I am using Sugarcube 2.0 in the text, but it is actually 1.0.32 that I am working with. I hope it did not make my question too confusing.
  • First. You really should be using SugarCube v2.


    You should be able to use the :hover pseudo class to toggle the foreground color between transparent and its normal color to achieve the effect you want. For example, add the following to your styles: (goes in Story Stylesheet)
    .secret {
    	color: transparent;
    }
    .secret:hover {
    	color: inherit;
    }
    

    Using it:
    @.secret;be made secretive@@
    
  • Thank you so much! It looks great. Can I also ask how difficult it would be to change to SugarCube 2.0? Would I need to rewrite anything?
  • I can't really answer that without knowing what features you're using.

    SugarCube v2 contains compatibility shims/layers for most things, to make the transition from v1 easier. It also contains all of the same basic markup and macros, in addition to newer features.

    The only thing that changed without any kind of compatibility shim/layer is v1's Options system—which, honestly, was shite. It was replaced by v2's Setting API.

    For a basic overview, go to the Upgrade Instructions for 2.x page of SugarCube v2's website and take a look at the Upgrading to any release ≥2.0.0 section. There's a lot of stuff in there, but you don't have to worry about things you're not using.

    Looking at SugarCube v2's documentation may also prove useful.
  • I'll look into it. Thanks again!
Sign In or Register to comment.