Author Topic: How would one code a Rolling Health Meter (ala Earthbound) in NGUI  (Read 19873 times)

fengshuifever

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 8
    • View Profile
Basically the topic subject says it all, how would one go about creating a rolling health meter like Earthbound in a graphical or number-based way using NGUI.
For those unaware of how Earthbound does it, essentially when you get hit, your character's health meter rapidly ticks down but you'll be able to still attack and assign commands as long as your character's HP does not reach 0.

The next question would be would I tackle this through NGUI or would it be better to do it through regular Unity scripting then apply imagery to it using NGUI.

Thanks in advance!

devomage

  • Sr. Member
  • ****
  • Thank You
  • -Given: 7
  • -Receive: 67
  • Posts: 250
    • View Profile
Re: How would one code a Rolling Health Meter (ala Earthbound) in NGUI
« Reply #1 on: November 01, 2015, 04:30:17 PM »
an image or example of what you are trying to accomplish would be helpful...

fengshuifever

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 8
    • View Profile
Re: How would one code a Rolling Health Meter (ala Earthbound) in NGUI
« Reply #2 on: November 01, 2015, 10:00:24 PM »
an image or example of what you are trying to accomplish would be helpful...

Oh, apologies! I thought the description would've been enough and the game reference BUT here's a youtube clip at the time of battle https://youtu.be/8nMh_Zys7Xg?t=1024
(if it doesn't jump to the point in the video, the timestamp is 17:14)

You can see in the video that Ness gets attacked and his health ticks down to the desired Health. (so it ticks down to 19 from 27 -- 8 HP Damage)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How would one code a Rolling Health Meter (ala Earthbound) in NGUI
« Reply #3 on: November 04, 2015, 12:38:12 PM »
Extremely trivial. Create a scroll view with numbers in it. Use SpringPanel.Begin to tween to a specific number's position when you need it to scroll to it. Can use an endless scroll view as well like in the last example that comes with NGUI.

fengshuifever

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 8
    • View Profile
Re: How would one code a Rolling Health Meter (ala Earthbound) in NGUI
« Reply #4 on: December 04, 2015, 02:17:51 AM »
Gotcha!

My only other question is how would I convert an int (let's say Health is 30) to the individual positions of the scroll view's sprites ( 0 0 3 0) or would that be more of a general programming question rather than a NGUI question?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How would one code a Rolling Health Meter (ala Earthbound) in NGUI
« Reply #5 on: December 09, 2015, 01:36:09 PM »
You'll be using 4 scroll views in that case, scrolling each digit individually. Having a list of sprites (or just find them by name if you named them like "1", "2", etc), you have the position needed to tween to.