Skip to content

Instantly share code, notes, and snippets.

@wpalmer
Created January 25, 2011 20:54
Show Gist options
  • Save wpalmer/795638 to your computer and use it in GitHub Desktop.
Save wpalmer/795638 to your computer and use it in GitHub Desktop.
diff --git a/web/js/game.js b/web/js/game.js
index ee569f7..aff43b3 100644
--- a/web/js/game.js
+++ b/web/js/game.js
@@ -169,7 +169,7 @@ $(function(){
.addSprite( "walk_left", {posx: 0, posy: 0, width: PLAYER_WIDTH, height: PLAYER_HEIGHT} )
.addSprite( "walk_right", {posx: 0, posy: 0, width: PLAYER_WIDTH, height: PLAYER_HEIGHT} );
-
+ var _handle;
var _anims = [
{
name: 'player-c64',
@@ -201,12 +201,15 @@ $(function(){
imageURL: "/img/game/snaps/"+(Math.floor(Math.random()*155)+1)+".png",
type: $.gameQuery.ANIMATION_CALLBACK
});
- setTimeout( function() {
- $("#c64").setAnimation(
- _anims[0].anim_sets[0].anims[2].animation,
- _anims[0].anim_sets[0].anims[2].callback
- );
- }, 3000);
+ if( !_handle ){
+ _handle = setTimeout( function() {
+ $("#c64").setAnimation(
+ _anims[0].anim_sets[0].anims[2].animation,
+ _anims[0].anim_sets[0].anims[2].callback
+ );
+ _handle = undefined;
+ }, 3000);
+ }
},
animation: new $.gameQuery.Animation({
imageURL: "/img/game/decrunch.png",
@@ -218,12 +221,15 @@ $(function(){
},
{
x: 832, y: 230, w: 102, h:64, callback: function(){
- setTimeout( function() {
- $("#c64").setAnimation(
- _anims[0].anim_sets[0].anims[0].animation,
- _anims[0].anim_sets[0].anims[0].callback
- );
- }, 10000);
+ if( !_handle ){
+ _handle = setTimeout( function() {
+ $("#c64").setAnimation(
+ _anims[0].anim_sets[0].anims[0].animation,
+ _anims[0].anim_sets[0].anims[0].callback
+ );
+ _handle = undefined;
+ }, 10000);
+ }
},
animation: new $.gameQuery.Animation({
imageURL: "/img/game/snaps/"+(Math.floor(Math.random()*155)+1)+".png",
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment