Last active
December 27, 2015 10:09
-
-
Save keesey/7308888 to your computer and use it in GitHub Desktop.
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
var CHANCE_OF_LIGHTNING = 1 / 100; // Tweak this. | |
var TOTAL_FRAMES = 4; // Include 'still' frame and lightning frames. | |
this.stop(); | |
this.addEventListener('tick', function() | |
{ | |
if (Math.random() < CHANCE_OF_LIGHTNING) | |
{ | |
this.gotoAndStop(Math.floor(Math.random() * (TOTAL_FRAMES - 1)) + 1); | |
} | |
else | |
{ | |
this.gotoAndStop(0); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment