Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Ok I've got the click function to work. Finally ^_^.</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;&lt;/title&gt; &lt;script type="text/javascript" src="https://github.com/DmitryBaranovskiy/raphael/raw/master/raphael-min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="http://code.jquery.com/jquery-1.6.1.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; /* GLOBAL VARIABLES */ var drawFrames; var canvas; var ctx; var universe = new Array(); var tile; var pX,pY = 0; universe = ( [[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]], [[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]], [[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]], [[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]], [[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]], [[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]], [[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]], [[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]], [[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]], [[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]] ); /* WINDOW LOAD */ window.onload = function() { init(); } /* INITIALISATION */ function init() { ctx = Raphael(10, 50, 320, 200); drawFrames = setInterval(drawFrame, 40); } /* FRAME RENDER LOOP */ function drawFrame() { //ctx.clear(); for (var x = 0; x &lt; universe.length; x++) { for (var y = 0; y &lt; universe[x].length; y++) { for (var i= 0; i &lt; 11; i++) { tile = ctx.rect(x*10,y*(i*10),10,10).attr({ fill:'#000000', stroke: '#ffffff' }).click(function(e) { console.log('x: '+e.pageX+'| y:'+e.pageY); }) } } } } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;canvas id="main" width="800" height="600"&gt; &lt;h1&gt;No Support I'm Afraid...&lt;/h1&gt; &lt;/canvas&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
 

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