Created
August 30, 2014 19:21
-
-
Save edwardsanchez/6bd57e31edbaee37c6a6 to your computer and use it in GitHub Desktop.
Simulates string being typed with realistic delays
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Name = new Layer width:400, x: 120, y:540, z:4, opacity:1, backgroundColor: "blue" | |
Name.html = "" | |
Name.style = | |
fontSize: '64px' | |
textAlign: 'center' | |
fontFamily: 'HelveticaNeue-Light' | |
lineHeight: '125px' | |
Name.on Events.TouchStart, -> | |
#Text to be typed | |
string = "Edward" | |
index = 0 | |
typeCharacter = () -> | |
#Updating text, remove +"|" if you don't want cursor showing | |
Name.html = string[0..index]+"|" | |
index++ | |
if index < string.length | |
#randomizes delay between keystrokes to simulate realistic typing | |
setTimeout typeCharacter, Math.random()*400 | |
#adds 2 second delay to start | |
Utils.delay(2, typeCharacter) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Would be nice if someone could add an animation for the cursor to blink continuously.