Note that there are some explanatory texts on larger screens.

plurals
  1. POJQuery recursive function in PhoneGap
    primarykey
    data
    text
    <p>I have been experimenting with PhoneGap and managed to create a basic memory game, which fades a sequence of numbers in and out, expecting the user to repeat it correctly. There's only the bare bones so you wont get any confirmation of a click until you finish the sequence.</p> <p>The game can be accessed here: <a href="http://jdtremelling.com/mobile/index.html" rel="nofollow noreferrer">http://jdtremelling.com/mobile/index.html</a></p> <p>And if you fancy it, for testing purposes, the app can be downloaded by scanning this QR code: <img src="https://i.stack.imgur.com/c8vxe.png" alt="enter image description here"></p> <p>The problem is that only one number flashes in the sequence when the app loads and then nothing else happens. Its as if the recursive function never executes. </p> <p>The code to initialise the JS array with lists of random numbers (increasing the sizes for each level) , then show the first sequence:</p> <pre><code>function initialiseArrays(){ for(var i=4; i&lt;9; i++){ var numbers = []; for(var j=0; j&lt;i; j++){ numbers.push(Math.floor(Math.random() * (max - min) + min)); } allNumbers.push(numbers.slice()); } fadeThemOut(allNumbers[0]); } </code></pre> <p>The recursive JavaScript funciton:</p> <pre><code> function fadeThemOut(children) { var tmp = []; for(var i=0; i&lt;children.length; i++){ tmp[i] = children[i]; } if (tmp.length &gt; 0) { var currentChild = tmp.shift(); switch(currentChild){ case 1: $('#one').fadeOut('slow').delay( 800 ).fadeIn('slow', function() { fadeThemOut(tmp); }); break; case 2: $('#two').fadeOut('slow').delay( 800 ).fadeIn('slow', function() { fadeThemOut(tmp); }); break; case 3: $('#three').fadeOut('slow').delay( 800 ).fadeIn('slow', function() { fadeThemOut(tmp); }); break; } } } </code></pre>
    singulars
    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.
 

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