지금 당장. 내 캐릭터의 방향에서 총알을 쏘도록 설정했습니다. 하지만 마우스 포인트로 총알을 쏠 수 있기를 원하며 플레이어가 더 쉽게 사용할 수있게하려고합니다.HTML5 캔버스 게임을 마우스 포인트로 움직입니다.
은 지금은 내가 마우스가 클릭 된 곳의 위치로 촬영 할 수 있도록하려면
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){ gun_1[i].y += gun_1[i].speed * modifier; gun_1[i].x += gun_1[i].speed * modifier };
입니다. 만약에 가능하다면.
제안 ...'switch'; – Orangepill