基本上我想将一个对象从A点(10x,10y)移动到画布上单击鼠标的位置(255x,34y).
我目前正在使用一种方法,但它从++ X然后是++ Y到坐标; 然后是正确的.
我希望它直接进入位置,喜欢路径上的动画.从A点到B点减速.
马上.我有它设置从我的角色方向射击子弹.但我希望能够向鼠标点射子弹,让玩家更轻松.
现在是的
if(gun_1[i].direction == 2){ gun_1[i].x -= gun_1[i].speed * modifier};
if(gun_1[i].direction == 3){ gun_1[i].x += gun_1[i].speed * modifier};
if(gun_1[i].direction == 1){ gun_1[i].y -= gun_1[i].speed * modifier};
if(gun_1[i].direction == 4){ gun_1[i].y += gun_1[i].speed * modifier };
if(gun_1[i].direction == 5){ gun_1[i].y -= gun_1[i].speed * modifier; gun_1[i].x -= gun_1[i].speed * modifier };
if(gun_1[i].direction == 7){ gun_1[i].y += gun_1[i].speed * modifier; gun_1[i].x -= gun_1[i].speed * modifier };
if(gun_1[i].direction == 6){ gun_1[i].y -= gun_1[i].speed * modifier; gun_1[i].x += gun_1[i].speed * modifier };
if(gun_1[i].direction == 8){ …Run Code Online (Sandbox Code Playgroud) 我试图弄清楚如果过了10分钟,那么就会发生一个动作。现在我所拥有的只是这个,我不太了解时间戳记。例如1370246236916 ...时,时,日,年,分钟或秒等在哪里。
var ten_mins = new Date().getTime();
var time = data_base_time;
var time_to_ago = time - new Date().getTime()+100000;
if( time >= time_to_ago){
//Ten minutes went by
}
Run Code Online (Sandbox Code Playgroud)