Question by Liam Macmillan: Javascript – Need some help?
Hello, I am making a game with JQuery..
How would I make it so when you click on something, a div appear’s where the character is standing?
This is some of my code..
$ (document).keydown(function(e) {
//alert(e.keyCode);
var position = $ (“#player”).position();
switch (e.keyCode)
{
case 37: // Left
$ (“#player”).css(‘left’, position.left – 10 + ‘px’);
break;
case 38: // Up
$ (“#player”).css(‘top’, position.top – 10 + ‘px’);
break;
case 39: // Right
$ (“#player”).css(‘left’, position.left + 10 + ‘px’);
break;
case 40: // Down
$ (“#player”).css(‘top’, position.top + 10 + ‘px’);
break;
case 27: //Esc
$ (‘#menu’).toggle();
}
});
Hope someone can help?
Many thanks, Liam
Best answer:
Give your answer to this question below!
Revisions
There are no revisions for this post.
No comments yet.