PlayMaker Help & Tips > PlayMaker Help

Marking the game distance

(1/1)

jongkook:
I am going to mark the distance on game screen as the game ‘Jetpack’.

Jetpack game : https://itunes.apple.com/us/app/jetpack-joyride/id457446957?mt=8

It takes a form to fix the characters but move only the background.
I pose this question because I tried to express the distance value based on time but had difficulties.

The below is c# code of a similar example;
------
 public void METERUPDATE ()
 {
          Meter += Time.deltaTime * GameSpeed;
          Meter_Label.text = string.Format ("{0:N0}<color=#ff3366> m</color>", Meter);
 }

------
How could I implement this with Playmaker?

escpodgames:
Create a state with a float add action and simple add the game speed per second.

jongkook:
I'm sorry.  I don't know how to do it.

sebaslive:
make an empty game object and call it game manager. Give it an FSM called Distance Traveled. On the start state add the action Float add. Make a variable called timer and make it a float.

In the action float add, set the variable as timer. set the add to 1 and check every frame and per second. Make another action called convert float to int and create a new int variable called realTimer. Set the float to timer and int to realTimer and rounding to Round Up.

Last we need to set this to a string to display. So another action called convert int to string. Create a new string variable and call it distance. Set the int to realTimer and the string to Distance. You can also set the format to 0000 so it starts with the 0's and counts up.

Use this string with whatever way you want to display it, ngui, 2dtoolkit, unity gui, etc. I would recommend going through all the playmaker tutorials that covers this and more!

jongkook:
Thanks sebaslive.
The problem has been fixed.

Navigation

[0] Message Index

Go to full version