Witam , mam drobny problem z ustawieniem kierunku myszki . Podczas gdy moja postać jest obrócona w prawą stronę , to ręka działa prawidłowo . Niestety po obrocie bohatera w lewą stronę - ręka zaczyna działać " odwrotnie " tzn obraca się 180 stopni od kierunku celownika.
Kod ręki :
GML
//create:
image_speed=0.3
//end step
x=oPlayer.x;
y=oPlayer.y;
if(oPlayer.image_xscale == -1)
{
targetdir = point_direction(x, y, mouse_x, mouse_y) - 180;
image_xscale=-1
}
else
{
targetdir = point_direction(x, y, mouse_x, mouse_y)
image_xscale=1
}
targetdir = point_direction(x, y, mouse_x, mouse_y)
diff = angdiff(direction, targetdir);
direction -= diff * 0.1;
//draw
if global.bron=0
{
draw_sprite_ext( sRekaBB,image_index,x,y,image_xscale,image_yscale,direction,image_blend,image_alpha);
}
if global.bron=1
{
draw_sprite_ext( sRekaZPistol,image_index,x,y,image_xscale,image_yscale,direction,image_blend,image_alpha);
}
Skrypt angdiff:
GML
return ((((argument0-argument1) mod 360) +540) mod 360) -180;