0
下面是遊戲:link爲什麼我的性格扭曲的differen地方
當你點擊一個不同的瓷磚字符應該走有慢。但是,如果您在走路時點擊另一個瓷磚,則字符會彎曲到該位置。我無法弄清楚爲什麼。
if(humanSelected && !moving)
{
moving=true;
var tileSpeed = 200;//ms
var x = $that.attr('x');//destination point
var y = $that.attr('y');
var diffx = humanSelected.x-x;//distance to cover in x-axis
var diffy = humanSelected.y-y;
var dist = Math.sqrt((diffx *diffx)+(diffy *diffy));//the distance in diagonal(straight line)
$('.man').animate({
right: diffx*20,
bottom: diffy*20
}, tileSpeed*dist, function() {
var mytile = tile(humanSelected.x,humanSelected.y);//get source tile object
$('img.man').remove('');//remove character from previous tile
humanSelected.x=x;humanSelected.y=y;
$that.html('<img src="man.gif" class="man"/>').attr('contain', 'man').css({right:0,bottom:0});//put character on new tile
moving=false;
});
$('.div').mouseup(function(){
var rx = $(this).attr('x');
var ry = $(this).attr('y');
humanSelected = new Object();
humanSelected={
x:rx,
y:ry
};
});
[Stack Overflow不接受「排查我的代碼」問題](http://meta.stackexchange.com/questions/40164/should-we-close-fix-my-program-questions)。您是否可以通過顯示迄今爲止採取的步驟來解決問題來縮小問題的範圍? – 2013-04-06 18:41:38
我已經添加了變量移動是布爾值,並且不應允許在對象移動時創建另一個目標點,但它沒有區別 – Dharman 2013-04-06 18:43:28
當您在移動過程中單擊時,您想要什麼?你想要第一步完成或被中斷?順便說一句,在乘法之前不需要使用abs(diffx):你可以直接使用diffx * diffx。 – 2013-04-06 18:43:33