How do I make a minute and second timer?

Get help using Construct 2

Post » Mon Jun 16, 2014 4:44 am

In another game I'm working on I'm using a minute and second time, but instead of subtracting I need to add to it where it starts at 00:00 and ends at whenever you finish the game.
B
10
S
1
Posts: 69
Reputation: 641

Post » Mon Jun 16, 2014 9:15 am

You will need to add variables one for minutes and one for seconds.
Every tick
--> add dt (delta-time) to seconds

If seconds >= (is more or equal) 60 (because there are 60seconds in a minute)
--> Add 1 to minutes
--> Subtract 60 from seconds

And just pack it all in, in a Timer running boolean or whatever you want to stop/start it.
And if you want it in a text object do:
Set text to Minutes&floor(Seconds)
(\__/)

(='.'=)

(")_(")
B
23
S
10
G
1
Posts: 74
Reputation: 3,244

Post » Tue Jun 17, 2014 1:04 am

TheNormalGeek wrote:You will need to add variables one for minutes and one for seconds.
Every tick
--> add dt (delta-time) to seconds

If seconds >= (is more or equal) 60 (because there are 60seconds in a minute)
--> Add 1 to minutes
--> Subtract 60 from seconds

And just pack it all in, in a Timer running boolean or whatever you want to stop/start it.
And if you want it in a text object do:
Set text to Minutes&floor(Seconds)


Could you make some images for this too please? I kinda get deer in headlights at text only. :oops:
B
10
S
1
Posts: 69
Reputation: 641

Post » Tue Jun 17, 2014 8:55 am

Here is a commented capx.
You do not have the required permissions to view the files attached to this post.
(\__/)

(='.'=)

(")_(")
B
23
S
10
G
1
Posts: 74
Reputation: 3,244

Post » Tue Jun 17, 2014 6:07 pm

Thanks!

Edit: Okay I've gotten most of my variables set up, and in the case of the timer starting automatically do I set the variables to constant?

Edit Edit: Okay I just tried and that didn't work.
B
10
S
1
Posts: 69
Reputation: 641

Post » Tue Jun 17, 2014 8:07 pm

You need to set local variables to static if not they will reset. (That's how local variables work)
If you want it to start on the start of layout just do
On start of layout --> Set Running to 1
(\__/)

(='.'=)

(")_(")
B
23
S
10
G
1
Posts: 74
Reputation: 3,244

Post » Tue Jun 17, 2014 8:43 pm

Okay it's working now. thanks.

Edit: I've run into another problem...the clock is working okay but in a separate file where I've added the events for the sandwiches and fillings to appear, since I haven't figured out how to set it up so only one sandwich and it's repsective filling pattern appears one at a time the clock stops at 4 seconds. Is this because I have so many sprites on screen?
B
10
S
1
Posts: 69
Reputation: 641

Post » Wed Jun 18, 2014 1:04 pm

I didn't understand do younwant something to happen after 4seconds?¨
What do you mean by " sandwiches and fillings "
(\__/)

(='.'=)

(")_(")
B
23
S
10
G
1
Posts: 74
Reputation: 3,244

Post » Wed Jun 18, 2014 5:01 pm

let me redirect you to my other topic: viewtopic.php?f=147&t=108317

basically my clock just froze at 4 seconds.
B
10
S
1
Posts: 69
Reputation: 641

Post » Thu Jun 19, 2014 12:51 pm

Do you have anything that sets timer running to 0?
(\__/)

(='.'=)

(")_(")
B
23
S
10
G
1
Posts: 74
Reputation: 3,244

Next

Return to How do I....?

Who is online

Users browsing this forum: 25games, Artcadev, mekonbekon and 24 guests