Skip to content

Instantly share code, notes, and snippets.

@richtaur
Created March 14, 2012 05:53
Show Gist options
  • Save richtaur/2034407 to your computer and use it in GitHub Desktop.
Save richtaur/2034407 to your computer and use it in GitHub Desktop.
Part of a polish tutorial
// Have the heart container "pop" in
polish.popIn(this, bind(this, function () {
// Wait a moment, then start to flicker away… then disappear
var numFlashes = 20;
this.numFlashes = 1;
// Wait 1 second
this.delayTween(1000);
// Add flashes to the queue
for (var i = 0; i < numFlashes; ++i) {
this.delayTween((30 - i) * 6, bind(this, function () {
// Toggle opacity
this.opacity = this.opacity == 1 ? 0 : 1;
// Gone through all the flashes? Then remove it
if (++this.numFlashes == numFlashes) {
this.remove();
}
}));
}
}));
@louisstow
Copy link

this.opacity ^= 1;

Yay XOR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment