Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: jongkook on April 09, 2014, 03:48:01 AM

Title: Marking the game distance
Post by: jongkook on April 09, 2014, 03:48:01 AM
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?
Title: Re: Marking the game distance
Post by: escpodgames on April 09, 2014, 05:28:42 AM
Create a state with a float add action and simple add the game speed per second.
Title: Re: Marking the game distance
Post by: jongkook on April 09, 2014, 10:24:20 AM
I'm sorry.  I don't know how to do it.
Title: Re: Marking the game distance
Post by: sebaslive on April 09, 2014, 12:47:11 PM
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!
Title: Re: Marking the game distance
Post by: jongkook on April 09, 2014, 01:42:18 PM
Thanks sebaslive.
The problem has been fixed.