8observer8 — 2013-10-01T16:37:32-04:00 — #1
I cannot move div by A, W, D, S keys: http://jsfiddle.net/8Observer8/mHAHz/128/
thetenfold — 2013-10-01T19:30:43-04:00 — #2
1) You don't match the right keys. It might be browser specific, not sure with jQuery, but mine are different than what you input.
2) You do
Gotta match the class, not a
3) You need to add a 'position' attribute to the square's css properties.
Try this: http://jsfiddle.net/mHAHz/130/
solidcodes — 2013-10-01T22:07:13-04:00 — #3
8observer8 — 2013-10-02T01:57:00-04:00 — #4
Thank you very much! How to move continuously (very fast and continuously)?
thetenfold — 2013-10-02T21:07:01-04:00 — #5
What do you mean continuously? back and forth? Use window.setInterval to find when it gets to either side and have it fade the opposite way.
8observer8 — 2013-10-03T03:27:03-04:00 — #6
I want to move div how a "small car".
stomme_poes — 2013-10-03T11:02:35-04:00 — #7
I think this div needs to be moved like Link in Legend of Zelda. So instead, he probably needs to listen for repeated key events as the key is held down (the key keeps making new events while it is held down?).
Probably the script is slow because for each key it's findgin .square again and again. It should be faster if .square is found once and saved into a variable. Before document.onkeydown event listener.
system — 2013-10-03T15:52:02-04:00 — #8
8observer8 — 2013-10-03T16:11:44-04:00 — #9
Thank you very much! This is the example from your link: http://jsfiddle.net/bDMnX/7/ I wanted to make this. Thanks!