Jump to content


Photo

Problem with enemy sprites


  • Please log in to reply
3 replies to this topic

#1 Hubster

Hubster

    GMC Member

  • New Member
  • 6 posts
  • Version:GM8

Posted 12 June 2012 - 12:58 PM

I don't know how can i do that an enemy go in a path, and at the ssme time, it change its sprite to enemy_right, enemy_left....
i prefer a gml code, but i can drag and drop too.
:confused:
  • 0

#2 mrokke96

mrokke96

    GMC Member

  • New Member
  • 256 posts
  • Version:GM8

Posted 12 June 2012 - 01:29 PM

I don't know how can i do that an enemy go in a path, and at the ssme time, it change its sprite to enemy_right, enemy_left....
i prefer a gml code, but i can drag and drop too.
:confused:

Do you want it so that the enemy only can face 0, 90, 180 and 270 degrees?? or do you want him to face in the exact direction as he is going?? I guess the first(considering to your post), and in that case i guess:
if direction < 45 && direction > 315
{
   sprite_index = enemy_right; // Facing right
}
if direction < 315 && direction > 225
{
   sprite_index = enemy_down; // Facing down
}
if direction < 225 && direction > 135
{
   sprite_index = enemy_left; // Facing left
}
if direction < 135 && direction > 45
{
   sprite_index = enemy_up; // Facing up
} 
EDIT: sorry, forgot that you wanted different sprites, but i fixed it now and i think it should work

Edited by mrokke96, 12 June 2012 - 01:32 PM.

  • 1

#3 M.D.Simmo

M.D.Simmo

    -- ·- - -

  • GMC Member
  • 204 posts
  • Version:GM8.1

Posted 12 June 2012 - 01:29 PM

Maybe something like this
if x-xprevious > 0 {
    sprite_index = spr_leftImage;
}
if x-xprevious < 0 {
    sprite_index = spr_rightImage;
}

EDIT:
Or, if you want it to rotate smoothly:
draw_sprite_ext(spr_rightImage,-1,x,y,1,1,direction,c_white,1)

Edited by M.D.Simmo, 12 June 2012 - 01:33 PM.

  • 0

#4 Hubster

Hubster

    GMC Member

  • New Member
  • 6 posts
  • Version:GM8

Posted 12 June 2012 - 01:36 PM

thanks, now i can finish my game!!!! :woot:
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users