Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript HTML5画布距离和移动对象_Javascript_Html_Canvas - Fatal编程技术网

Javascript HTML5画布距离和移动对象

Javascript HTML5画布距离和移动对象,javascript,html,canvas,Javascript,Html,Canvas,我有一个返回的距离函数:distance类似于:15、10等。 此处功能: var Distance = function( other ) { var xd = other.x - this.x; var yd = other.y - this.y; return Math.sqrt( xd * xd + yd * yd ); }; 并具有在中有位置的Bullet函数。x=10;这个y=10 但是我的子弹如何随着距离移动呢?就像塔楼防御游戏中塔楼向敌人射击一样 感谢并为我糟糕的英语语言感到抱

我有一个返回的距离函数:
distance
类似于:15、10等。 此处功能:

var Distance = function( other ) {
var xd = other.x - this.x;
var yd = other.y - this.y;
return Math.sqrt( xd * xd + yd * yd );
};
并具有在
中有位置的Bullet函数。x=10;这个y=10

但是我的子弹如何随着距离移动呢?就像塔楼防御游戏中塔楼向敌人射击一样


感谢并为我糟糕的英语语言感到抱歉。

你的子弹可能会随着
dt
及其速度的变化而移动。到潜在目标的距离是碰撞检测的一个特征,应该独立评估