playMaker

Author Topic: Next frame event on both state  (Read 1740 times)

kentcheung2000

  • Playmaker Newbie
  • *
  • Posts: 37
Next frame event on both state
« on: May 08, 2018, 11:58:28 PM »
Hi,

I am making a health bar following the tutorial in the link.  I made two "next frame event" on both states.  When the game start, I see there a loop which constantly updating the number.  Everything works.

My question is that is it good practice to put two next frame event on both sides? It kind of look like infinite loop because I see light flashing on both side when the game running...

KC

At 7:10


djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Next frame event on both state
« Reply #1 on: May 09, 2018, 10:36:10 AM »
Hi,
I just took a quick look but i don't think that he uses a good setup.

To show the text you can you use a single state, convert to string and display the string just like in the video but without next frame event.

You can set the actions to 'Every frame' to update every frame OR
You can use a 'send event' to the fsm whenever hp is added or removed.
then un-check every frame OR

You could use a state before that one and use the action : float changed
also un-check every frame and point back to the float changed state.

For the hp bar part, the same principals as for the text

You can place every thing i a single state (for the line and the text)

So the state would have :
Get Fsm Int
Convert Int To String
Ngui Update Label Text (or ugui set text/ui set text)
Convert Int To Float
Float Operator
action to fill (this can be done in different ways without using the script)

and all "Every Frame" checked or uncheck depending on your setup.

Theoretically Every frame would be more "expensive" that the other options.

Practically you wont see any difference, if you would have 1000's of health bars you might see a difference.
But i think best practice is to also think about performance :)