Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Topics - hyrule_forest

#1
Development / Avoiding two sprite animation overlap
February 15, 2023, 10:33:59 PM
Hi everyone,

I have a problem with 2 animations which overlap. As you can see in attached file, and didn't arrive to have only one sprite at the same time,
I would like to have either the mob with hands in air, or the mob in appearing mode ...
Bellow my code part for changing sprite/animation:


sprite:register_event("on_frame_changed", function(sprite, animation, frame)
  sprite:stop_animation()
  if enemy:get_distance(hero) < waiting_distance then
    sprite:set_animation("waiting",
      function()
        is_underground = false
        enemy:set_hero_weapons_reactions({
          arrow = 2,
          boomerang = 2,
          explosion = 2,
          sword = 1,
          thrown_item = 2,
          fire = 2,
          jump_on = "ignored",
          hammer = 2,
          hookshot = 2,
          magic_powder = 2,
          shield = "protected",
          thrust = 2
        })
        enemy:set_can_attack(true)
      end
    )
  elseif enemy:get_distance(hero) < appearing_distance then
    sprite:set_animation("appearing",
      function()
        is_underground = false
        enemy:set_hero_weapons_reactions({
          arrow = 2,
          boomerang = 2,
          explosion = 2,
          sword = 1,
          thrown_item = 2,
          fire = 2,
          jump_on = "ignored",
          hammer = 2,
          hookshot = 2,
          magic_powder = 2,
          shield = "protected",
          thrust = 2
        })
        enemy:set_can_attack(true)
      end
    )
  else
    sprite:set_animation("walking",
      function()
        is_underground = false
        enemy:set_hero_weapons_reactions({
          arrow = "ignored",
          boomerang = "ignored",
          explosion = "ignored",
          sword = "ignored",
          thrown_item = "ignored",
          fire = "ignored",
          jump_on = "ignored",
          hammer = "ignored",
          hookshot = "ignored",
          magic_powder = "ignored",
          shield = "protected",
          thrust = "ignored",
        })
        enemy:set_can_attack(true)
      end
    )
  end
end)


Anyone can help me plz ?

Thank you so much  :) (I precise that I'm a beginner)