hallo,
habe ein problem das, wenn ich die taste w oder a,s,d oft hintereinander drücke überspringt er ein feld. kann mir bitte wer helfen
mfg
habe ein problem das, wenn ich die taste w oder a,s,d oft hintereinander drücke überspringt er ein feld. kann mir bitte wer helfen
mfg
Code:
<script type="text/javascript"> $(document).ready(function() { $(document).keyup(function(event) { var key = String.fromCharCode(event.keyCode); key.toUpperCase(); switch(key) { case "W": $(".block").css("background-image", "url(/img/figur.png)"); $.getJSON( "/ajax/ajax1.php?1=W", function( data ) { if(data.laufbar == 1) { $( ".block" ).filter(":not(:animated)").animate({ "bottom": (data.y*64-64)+"px", "left": (data.x*64-64)+"px" }, "fast" ); } }); break; case "A": $(".block").css("background-image", "url(/img/figur.png)"); $.getJSON( "/ajax/ajax1.php?1=A", function( data ) { if(data.laufbar == 1) { /*$( ".block" ).filter(":not(:animated)").animate({ "left": "-=64px" }, "fast" );*/ $( ".block" ).filter(":not(:animated)").animate({ "bottom": (data.y*64-64)+"px", "left": (data.x*64-64)+"px" }, "fast" ); } }); break; case "D": $(".block").css("background-image", "url(/img/figur.png)"); $.getJSON( "/ajax/ajax1.php?1=D", function( data ) { if(data.laufbar == 1) { /*$( ".block" ).filter(":not(:animated)").animate({ "left": "+=64px" }, "fast" );*/ $( ".block" ).filter(":not(:animated)").animate({ "bottom": (data.y*64-64)+"px", "left": (data.x*64-64)+"px" }, "fast" ); } }); break; case "S": $(".block").css("background-image", "url(/img/figur.png)"); $.getJSON( "/ajax/ajax1.php?1=S", function( data ) { if(data.laufbar == 1) { /*$( ".block" ).filter(":not(:animated)").animate({ "bottom": "-=64px" }, "fast" );*/ $( ".block" ).filter(":not(:animated)").animate({ "bottom": (data.y*64-64)+"px", "left": (data.x*64-64)+"px" }, "fast" ); } }); break; case "I": toggleDiv(inventar); break; } }); });
Kommentar