Author Topic: problem with event order execution on Android [World Map Strategy Kit]  (Read 84 times)

aberbery

  • Newbie
  • *
  • Posts: 7
    • View Profile
Hi,

I have an issue with World Map Strategy Kit on Android (when running on PC it works fine).

So its a war game and user suppose to trigger one country attacking another by dragging own finger from one country to another.

I tried to achieve that using 2 events "onMouseDown" and "onMouseRelease". In implementation of each I take "map.countryHighlighted" to figure out on which exact country mouse down or release  happened.

When I do this on PC with mouse all works fine. However when I build my unity project into Android and run it on tablet it does not work. Problem is that when "onMouseDown" is triggered "map.countryHighlighted" is null. For debugging purpose I also implemented "onCountryEnter". What I saw is that on Android device "onCountryEnter" is triggered after "onMouseDown" and I assume that is the reason why "map.countryHighlighted" ends up being null.

Can you please advice how to overcome this issue, or maybe another method of catching event of dragging finger from one country to another? Its important for me that drag happens exactly on country and not on sprite (i.e. tank) on top of country.

Thanks In Advance.
« Last Edit: October 05, 2021, 09:04:52 PM by Kronnect »

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 7565
    • View Profile
Have you tried using OnCountryClick event instead?

You could try OnDragStart/OnDragEnd to detect when drag starts / ends and if countryHighlighted is null in OnDragEnd, you can try map.GetCountry(map.cursorLocation);
« Last Edit: October 05, 2021, 09:09:46 PM by Kronnect »

aberbery

  • Newbie
  • *
  • Posts: 7
    • View Profile
map.GetCountry(map.cursorLocation); was exactly what I needed, thanks a lot.