Note that there are some explanatory texts on larger screens.

plurals
  1. POdeveloping an external arrow keys using HTML5 Canvas
    primarykey
    data
    text
    <p>I'm trying to develop a game using html5, css and a little bit of jquery.</p> <p>Sometimes I have achieved to make the game work via Chrome and Firefox but not Safari. My issue is that during my experiment, on the iPad2 the game works except that the object is not moving, so I was looking for a solution to develop somehow an external key arrows without using many scripts, the object suppose to do only jump, left and right. I have looked for many solution to this I couldn't find a good rendered movement. I have even tried to create an JavaScript that handle the movements smoothly.</p> <p>I'm looking for a way to handle the movement via mobile using node.js or any available source that could help me achieving the smooth jump.</p> <p>I have looked for many resources and i want to make the controls as simple to users to interact with.</p> <p>Both Chrome and Firefox works well with no problem, except Safari specifically the one in iPad 2 or 3...</p> <p>Here is some of the controls , where is my mistake in this </p> <pre><code>var left, right; left = mie ? 1:0; right = 2; document.body.addEventListener('mousedown' , function (e) { console.log(e.button); if(key === left){ dir = "left"; player.isMovingLeft = true; } else if (key === right){ dir = "right"; player.isMovingRight = true; } if(key == 32) { if(firstRun === true) init(); else reset(); } }; var left, right; left = mie ? 1:0; right = 2; document.body.addEventListener('mouseup' , function (e) { console.log(e.button); if(key === left){ dir = "left"; player.isMovingLeft = false; } else if (key === right) { dir = "right"; player.isMovingRight = false; } }; //Accelerations produces when the user hold the keys if (player.isMovingLeft === true) { player.x += player.vx; player.vx -= 0.15; } else { player.x += player.vx; if (player.vx &lt; 0) player.vx += 0.1; } if (player.isMovingRight === true) { player.x += player.vx; player.vx += 0.15; } else { player.x += player.vx; if (player.vx &gt; 0) player.vx -= 0.1; } // Speed limits! if(player.vx &gt; 8) player.vx = 8; else if(player.vx &lt; -8) player.vx = -8; </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