我有一个2d布尔arrray,用于映射块的位置(如果坐标为true,则块位于那里)。我试图这样做,如果你点击某处,它将该位置设置为false,因此挖掘该块。我的mapgrid的单元格大小为10,因此如果我点击(200,1000),(20,100)应该在网格中设置为false。以下是我在<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<h1 id="title" style="blink_text" align="center">Loginator!</h1>
<fieldset class=r emoveMe>
<legend>First, enter your BCPS One username and password:</legend>
<label>Username:
<input type="text" class=r emoveMe id="real_username_field" />
</label>
<br />
<label>Password:
<input type="text" class=r emoveMe id="real_password_field" />
</label>
<br />
<input type="submit" class=r emoveMe id="mySubmit" value="Submit" onclick="credentials()" class=r emoveMe/>
</fieldset>
<br />
<p1 class=r emoveMe><var id="real_username" class=r emoveMe></p1>
<br />
<p1 class = removeMe><var id="real_password" class = removeMe></p1>
<br />
<label class = gametime>Username:<input id="game_username_field" class = gametime></label>
<br />
<label class = gametime>Password: <input id="game_password_field" class = gametime></label>
<br />
<!-- While loop/timer should start here-->
<button id = "button_game_start" onclick="game_login_entered()" class = gametime>log in</button>
<br />
<p3 id = user_feedback1 class = gametime></p3>
<br />
<p3 id = user_feedback2 class = gametime></p3>
<br />
<p3 id = user_feedback_score class = gametime></p3>
<br />
<p3 id = user_feedback_multiplier class = gametime></p3>
<!--This jquery code should make the enter key work when the focus is in the password feild, but it doesn't...-->
<script>
$(#game_password_field).keyup(function(event){
if(event.keyCode == 13){
$(#button_game_start).click();
}
});
</script>
<!--This hides the game form. We will show it in credentials() when the game starts. -->
<script>
$('.gametime').hide();
</script>
<p id="demo"></p>
<!--This button starts the timer. The function is called in credentials(). I would like to put this in the java section so we could customize the timer.-->
<!-- <button onclick="onTimer()">Play!</button> -->
<div id="mycounter" class = gametime></div>
<script>
i = 60;
function onTimer() {
document.getElementById('mycounter').innerHTML = "Time left: " + i;
i--;
if (i < 0) {
alert("Time's up!");
$('.gametime').hide();
return;
}
else {
setTimeout(onTimer, 1000);
}
}
</script>
InputListener
现在这几乎完美无缺,但是y起源仍然是左上角,我以为我正在修复这个我初始化tmp.y的方式,任何帮助都非常感激
答案 0 :(得分:0)
更改tmp.y以在取消投影后更改本地坐标
@Override
public boolean touchDragged(int screenX, int screenY, int pointer) {
tmp.x = screenX;
tmp.y = screenY;
tmp.z = 0;
cam.unproject(tmp);
grid.manipulateGrid((int)(tmp.x) / MapGrid.CELL_SIZE, (int)(tmp.y) / MapGrid.CELL_SIZE, false);
System.out.println("Clicked at: (" + tmp.x / MapGrid.CELL_SIZE + ", " + (Gdx.graphics.getHeight() - tmp.y) / MapGrid.CELL_SIZE +")");
return false;
}