Page 1 of 1

Additional JS event - HUD element value changed

Posted: Fri Jun 26, 2015 8:11 am
by phkb
Would it be possible to have an event to trigger whenever a change occurs on various HUD elements? For instance, speed increase/decrease, shield up/down, energy bank increase/decrease, that sort of thing. I've been playing around with creating a HUD with custom dials, and was trying to get a curved bar for things like speed, but when using a timer to check for changes the bar moves in a rather jerky way. There doesn't appear to be anyway to achieve this without using a timer, and I imagine running a timer for HUD elements would be quite a drain on resources. If there was an event the custom speed bar could be animated smoothly.

Of course, there might already be a way to do this - feel free to point out my ignorance! And if it's not possible, that's fine too. I'll stick with vertical/horiztonal bars!

Re: Additional JS event - HUD element value changed

Posted: Fri Jun 26, 2015 8:26 am
by another_commander
Rather than using a timer, why not use a frame callback to check if a value has changed? Frame callbacks are called by default in each frame, as suggested by the name.

Re: Additional JS event - HUD element value changed

Posted: Fri Jun 26, 2015 12:11 pm
by phkb
Ah! Looks like I have some learning to do! Thanks!