Note that there are some explanatory texts on larger screens.

plurals
  1. POCannot get set interval to work?
    primarykey
    data
    text
    <p>No matter what I do I cannot get this bit of code to work, the part where you set an interval in the draw method and will call the Loop method 4 times in two seconds, each call displaying a different image. Currently it shows nothing? And the issue is not with an images etc as it works with one image fine. Been at this for 2 days.. </p> <pre><code> function Explosion() //space weapon uses this { this.srcX = 0; this.srcY = 1250; this.drawX = 0; this.drawY = 0; this.width = 70; this.height = 70; this.currentFrame = 0; this.totalFrames = 10; this.hasHit = false; this.frame = 0; } Explosion.prototype.draw = function() { if(this.hasHit == true &amp;&amp; this.frame &lt; 5) { var t=setTimeout(Explosion.Loop,500); } if(this.frame == 5) { clearTimeout(t); this.hasHit = false; this.frame = 0; } } Explosion.prototype.Loop = function() { ctxExplosion.clearRect ( 0 , 0, canvasWidth , canvasHeight ); if(this.frame == 1) { ctxExplosion.drawImage(spriteImage,this.srcX,this.srcY,this.width,this.height,this.drawX,this.drawY,this.width,this.height); frame++; } else if(this.frame == 2) { ctxExplosion.drawImage(spriteImage,this.srcX,(this.srcY + 77),this.width,this.height,this.drawX,this.drawY,this.width,this.height); frame++; } else if(this.frame == 3) { ctxExplosion.drawImage(spriteImage,this.srcX,(this.srcY + 154),this.width,this.height,this.drawX,this.drawY,this.width,this.height); frame++; } else if(this.frame == 4) { ctxExplosion.drawImage(spriteImage,this.srcX,(this.srcY + 231),this.width,this.height,this.drawX,this.drawY,this.width,this.height); frame++; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload