Add-ons / <<shake>> Macro Set

Macros for applying a shaking animation to various element(s).

Author Thomas M. Edwards
Website http://www.motoslave.net/sugarcube/2/#downloads
Story format SugarCube 2
Last checked Sun Nov 27 2022
License BSD 2-Clause "Simplified" License
Download shake.zip

Index

Overview

SugarCube is a free (gratis and libre) story format for Twine/Twee, based on TiddlyWiki.

This documentation is a reference for the <<shake>> macro set for SugarCube, it assumes at least a passing knowledge of SugarCube macros.

Requirements

This package requires SugarCube v2.5.0 or later.

Contents

The files included in this package are:

Installation

JavaScript

  1. Open the shake-macro-set.min.js file in a text editor (not a word processor) and copy its contents.
  2. Paste them into your project's script section:
    • Twine 1: script-tagged passage.
    • Twine 2: Story JavaScript.

Stylesheet

  1. Open the shake-macro-set.css file in a text editor (not a word processor) and copy its contents.
  2. Paste them into your project's stylesheet section:
    • Twine 1: stylesheet-tagged passage.
    • Twine 2: Story Stylesheet.

Macros

<<shake>>

<<shake>>

Syntax: <<shake [duration]>>...<</shake>>

Applies a shaking animation to its contents.

Arguments:

Usage:

→ Shakes its contents until the player navigates away
<<shake>>EARTHQUAKE!  DUCK AND COVER!<</shake>>

→ Shakes its contents for 5s
<<shake 5s>>[img[scarey-face.jpg]]<</shake>>

<<shakescreen>>

<<shakescreen>>

Syntax: <<shakescreen [duration]>>

Applies a shaking animation to the passage container element (i.e. shakes the currently displayed passage).

Arguments:

Usage:

→ Shakes the passage until stopped stopped or the player navigates away
<<shakescreen>>
→ Shakes the passage for 5s
<<shakescreen 5s>>
→ Immediately stops shaking the passage
<<shakescreen stop>>

<<shaketarget>>

<<shaketarget>>

Syntax: <<shaketarget selector [duration]>>

Applies a shaking animation to the selected element(s).

Arguments:

Usage:

→ Shakes the target(s) until stopped stopped or the player navigates away
<<shaketarget "#creaky">>
→ Shakes the target(s) for 5s
<<shaketarget "#creaky" 5s>>
→ Immediately stops shaking the target(s)
<<shaketarget "#creaky" stop>>

Live demo

Demo Twee code:

:: Start
<<shake>>Help! I can't stop shaking.<</shake>>