Hrmmm ...建议,想法,毫无意义的评论? [英] Hrmmm...Suggestions, Ideas, Pointless Remarks?

查看:100
本文介绍了Hrmmm ...建议,想法,毫无意义的评论?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

理论上这是一个好主意:
http://www.backwater-productions.net...ame/index.html


按4按钮向左移动,按6键。向右移动。


问题仍然存在......是否存在一些限制

onkeypress的方法?因为如果你把钥匙放下来,男孩那就是所有

不满意的那种阴影吧。


:char_l_img = 1;

:char_r_img = 1;

:start_pos = 300;

:nav4 = window.Event? true:false;



:function move_left()

:{

:start_pos = start_pos - 5 ;

:char_l_img ++;

:if(start_pos == 25){start_pos = 30; }

:if(char_l_img == 5)

:{

:char_l_img =" 1" ;;

:window.clearInterval(farfoos);

:}

:document.getElementById(" char_div")。s​​tyle.left = start_pos +" px";

:document.getElementById(" char_img")。s​​rc =" l" + char_l_img +" .gif";

:}



:function move_right()

: {

:start_pos = start_pos + 5;

:char_r_img ++;

:if(start_pos == 500){start_pos = 495; }

:if(char_r_img == 5)

:{

:char_r_img =" 1";

:window.clearInterval(farfoos);

:}

:document.getElementById(" char_div")。s​​tyle.left = start_pos +" px";

:document.getElementById(" char_img")。s​​rc =" r" + char_r_img +" .gif";

:}



:功能移动(e)

:{

:if(nav4){whichCode = e.which; }

:else {whichCode = event.keyCode; }
:if(String.fromCharCode(whichCode)== 4&& char_l_img == 1){farfoos = window.setInterval(''move_left()'',35); }

:if(String.fromCharCode(whichCode)== 6&& char_r_img == 1){farfoos = window.setInterval(''move_right()'',35);} < br $> b $ b:}



:document.onkeypress = move;



:document.write("< div id =''char_div''style =''position:absolute; z-index:0; left:" + start_pos +" px; top:150px; width:32px height :64px''>< img id =''char_img''src =''r1.gif''>< / div>");


我试过那&& char_l_img == 1件事,但这似乎没有削减它。

是否有某种方法可以检测到什么时候没有按下钥匙?

Hrmmm ..我现在不知道这个,我想也许我需要

来睡觉。 -_-


我可能需要重新思考它实际运行的所有方式...也许在PHP中使用它...
它... ... hrmmm ... wonder如果PHP有等同的onkeypress ...


-


Onideus Mad Hatter

mhm 1 x 1
http://www.backwater-productions.net

Well in theory it was a good idea:
http://www.backwater-productions.net...ame/index.html

Press "4" to move left, press "6" to move right.

The question remains though...is there some way of limiting
onkeypress? Cause if you hold the key down, boy that''s just all
shades of unhappy right there.

: char_l_img = 1;
: char_r_img = 1;
: start_pos = 300;
: nav4 = window.Event ? true : false;
:
: function move_left()
: {
: start_pos = start_pos - 5;
: char_l_img++;
: if ( start_pos == 25 ) { start_pos = 30; }
: if ( char_l_img == 5 )
: {
: char_l_img = "1";
: window.clearInterval(farfoos);
: }
: document.getElementById("char_div").style.left = start_pos + "px";
: document.getElementById("char_img").src = "l" + char_l_img + ".gif";
: }
:
: function move_right()
: {
: start_pos = start_pos + 5;
: char_r_img++;
: if ( start_pos == 500 ) { start_pos = 495; }
: if ( char_r_img == 5 )
: {
: char_r_img = "1";
: window.clearInterval(farfoos);
: }
: document.getElementById("char_div").style.left = start_pos + "px";
: document.getElementById("char_img").src = "r" + char_r_img + ".gif";
: }
:
: function move(e)
: {
: if (nav4) { whichCode = e.which; }
: else { whichCode = event.keyCode; }
: if( String.fromCharCode(whichCode) == 4 && char_l_img == 1 ) { farfoos = window.setInterval(''move_left()'', 35); }
: if( String.fromCharCode(whichCode) == 6 && char_r_img == 1 ) { farfoos = window.setInterval(''move_right()'', 35);}
: }
:
: document.onkeypress = move;
:
: document.write("<div id=''char_div'' style=''position:absolute; z-index:0; left:" + start_pos + "px; top:150px; width:32px height:64px''><img id=''char_img'' src=''r1.gif''></div>");

I tried that && char_l_img == 1 thing, but that didn''t seem to cut it.
Is there some way to detect when a key is NOT being pushed?
Hrmmm...I''m at a loss on this one at the moment, I think maybe I need
to get some sleep. -_-

I might need to rethink the whole way it actually functions...maybe do
it in PHP...hrmmm...wonder if PHP has an onkeypress equivalent...

--

Onideus Mad Hatter
mhm 1 x 1
http://www.backwater-productions.net

推荐答案

我猜你从来没有为ZX Spectrum编程......它会让你的大脑

一次又一次地在正确的角度下:-)


onkeydown开始由你的内部

计时器调节的运动过程。


onkeyup停止运动过程并清除计时器。


由于PC / Mac键盘方法从一开始就很糟糕,所以它不可能是b $ b到达PC游戏没有你自己的键盘的功能

司机(所以说你可以拿一把钥匙继续前进并按下

其他钥匙射击/踢敌人)。 />

但原始动作相当简单:

....

var obj = null;

函数init(){

obj = document.getElementById(''Monkey'');

obj.onkeydown = moveIt;

obj .onkeyup = stopIt;

}


函数moveIt(){

/ *检查按下了什么键

和setTimeout用于相应的运动

功能(左/右/上/下)* /

}


函数stopIt(){

/ * clearTimeout * /

}


windows.onload = init;

....

I guess you never programmed for ZX Spectrum... It puts your brains
under the right angle once and for a while :-)

The onkeydown starts the process of movement regulated by your internal
timer.

The onkeyup stops the process of the movement and clears the timer.

As the PC/Mac keyboard approach sucks from the very beginning, it''s
impossible to reach a "PC Game" functionality w/o your own keyboard
driver (so say you could hold a key to keep moving forward and press
other keys to shoot/kick the enemies).

But a primitive movement is fairly simple:
....
var obj = null;
function init() {
obj = document.getElementById(''Monkey'');
obj.onkeydown = moveIt;
obj.onkeyup = stopIt;
}

function moveIt() {
/* Check what key is pressed
and setTimeout for the appropriate movement
function (left/right/up/down) */
}

function stopIt() {
/* clearTimeout */
}

windows.onload = init;
....


VK写道:

[...]
VK wrote:
[...]
windows.onload = init;
windows.onload = init;



-------- ^


这是在操作系统加载时运行的吗? :-)


-

Rob


--------^

This runs when the OS loads? :-)

--
Rob


>> windows.onload = init;
>> windows.onload = init;
这是在操作系统加载时运行的吗? : - )
This runs when the OS loads? :-)




那会很酷...... :-)


对不起,只是一个错字。当然:


window.onload = init;



That would be cool... :-)

Sorry, just a typo. Of course:

window.onload = init;


这篇关于Hrmmm ...建议,想法,毫无意义的评论?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆