Text timers... how do you do it?

This forum is currently in read-only mode.
From the Asset Store
Change delay, create new lines, "backspace" the text
  • Lots of platform games have a visual clock that counts down to zero, and the player has to reach a certain point or clear the board before it turns to zero causing the player to die.

    How do you create a visual timer that counts from any number you choose, down to zero... and then connect it to an event like:

    Number is zero = go to next layout

    I've searched the forum but can't find this information.

  • The visual representation can be done in so many ways (textbox, sprites, colors, etc) that you have to find yourself the most accurate one.

    The counter itself is very easy to implement. Create a global variable, give it the value of your choice, substract in certain steps (e.g. every 1000 miliseconds) and check if the global reaches <= 0

    For an example of how to visually represent time you may want to have a look at this thread (includes downloadable example)

  • I'm sorry, I don't quite understand what you're saying exactly.

    I have found how to make the text change, but I haven't figured out how to make it count down to 0-zero from a number like 25, without writing a very huge mount of lines with each separated by 1000 milliseconds.

    I was going to draw a graphic timer that counts down visually each second and then connect it to an event, but I'd rather make it text because a graphic one doesn't fit my game style.

  • I don't understand Global variables or how to use them and when to use them. So until there is a tutorial I'm going to use the Timeline Object.

    I'll depart from my original intent and just draw up an animated timer and set it to run by frame, and then set the actual time count in the background in miliseconds using the Timeline object. I'm able to link the end of the timeline to an event like jumping to another layout, etc. I've already tested it and it works.

    As a note, I'm finding the time-keeping accuracy to be a bit sluggish though. If I select 5,000ms (5 seconds) it actually takes about 6 seconds or a bit more (6.5 seconds?) for the linked event to trigger. I just find that the countdown is not consistently accurate.

  • Hello. I'm assuming that you basically have no experience in programming, from your comments above. If that's the case, you may have figured that you're a bit of a hard case to help. Given that you have figured out ways to make things work, such as using an object that frankly scares me (timeline), then don't give up.

    While Scirra has attempted to make make it less daunting, knowledge of programming is still needed, because setting up event sheets is, indeed, programming.

    Global variables are a very important aspect of programming in any language. In most cases, they represent values (of any given type of data) that can be accessed from within any scope of the program, and that may be changed at any time. In Construct's case, this means that they are shared among all layouts. Given global variables, and some simple conditional events based upon them, one can implement all sorts of things.

    As tulamide mentioned, they are a natural way to implement a timer.

    I've made a commented .cap with an example of a timer implemented in such a way. It sets up two similar layouts, each with a "Text" object to display the timer, where one starts manually and the other automatically. Note that the global variables are of numerical value and the "Text" object handles string values. Construct generally handles converting numbers into strings for use with objects such as the "Text" object quite transparently, as is noted in the .cap.

    I hope it helps (v0.99.84): http://dl.dropbox.com/u/5868916/Timer1.cap

    Also, I'd recommend checking out some beginner programming tutorials in general. I'm partial to Python, as it's widely regarded as easy for beginners, and can be used in Construct as well as on it's own. The concepts in normal computer programming and in event-based programming are very similar, naturally. If you're interested, here are some good resources:

    General beginner's guide: http://wiki.python.org/moin/BeginnersGuide

    A nice tutorial aimed at beginners: http://www.sthurlow.com/python/

    Another found from the first link that I liked: http://openbookproject.net/thinkcs/python/english2e/

    I should add that the two last links both start off with examples done from within the python interactive shell (IDLE), which is great for learning the basics. It simply executes individual commands or command blocks, letting you learn things step-by-step.

    I've also written a simpler version of that shell within Construct, using it's native Python support, so you wouldn't even need to install Python to try the interactive examples given in those. It's here if you're so inclined: http://www.scirra.com/forum/viewtopic.php?f=16&t=6158

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Hello. I'm assuming that you basically have no experience in programming, from your comments above. If that's the case, you may have figured that you're a bit of a hard case to help. Given that you have figured out ways to make things work, such as using an object that frankly scares me (timeline), then don't give up.

    While Scirra has attempted to make make it less daunting, knowledge of programming is still needed, because setting up event sheets is, indeed, programming.

    No, no, no. That part in bold is not true at all. Speaking as a long time C programmer who has worked on commercial games, having knowledge of C is fine but certainly not a requirement in the least bit to learning Construct or any event-based system for that matter. It wouldn't make a difference if you were the best C programmer who ever lived, it doesn't mean you're going to do well with this program and there are a lot of C guys who are frustrated to no end with these types of programs. The bottom line is, his question is just another thing that should have a focused tutorial and there isn't one, that's the problem... the user is not the problem... we have to stop blaming the user... the documentation isn't good enough or non-existent, that's the problem and why they're asking the questions to being with... besides that, programming a global variable in C is not the same as in Construct, so you can't say because they ask the question about Construct that means they've never programmed, lol.

    I think he's displayed that he has a general enough knowledge of what he's doing, but he probably needs a code example and that's part of the issue with a lot of the help section answers. We need to be giving code examples rather than just answers of a general direction... everyone doesn't learn just by general direction, and typically a true visual example is universally more apt to be understood.

    All of that said, if he says he's already figured out a different way to do what he wants, I don't see the point of even extending this. The Timeline Object works fine, and it may work fine for what he wants to do. Without knowing all the specifics of his game you're just assuming what works best for it without actually knowing. He may not even need to use global variables for what he's trying to do, perhaps he only needs an operation for one layout. Only he would know that.

  • You're attacking the wrong. We at least try to help - you don't.

    First of all, programming doesn't mean knowing C. Programming is a process of telling the computer, what you want him to do. You use whatever tools help you achieving this. C/C++/C#/Pascal/Basic/Construct/Flash/Python/lua ... you name it.

    Second, whatever tool you choose, there is a core part that is shared among all of them. That is the basics you need to know, wether you like it or not.

    Third, you need to have the wish to learn by doing.

    Really, that post sounds so arrogant, like you want to sit in your chair, crossing your arms and telling everybody: "Now feed me." And while you are complaining, that help has to be done your way of thinking, because that certainly is the only right way, as noone is right but you - while moaning so, you do nothing of all that. Not one single code example from you, no cap file, no wiki entry, nothing.

    I for one at least try to help, and btw I posted a link to an example cap file that covers all of it. So there is the visual example you're talking about, but I'm sure you don't know about it, because you hadn't have the time to revise it. Attacking the one's who are helping is much more important.

    Last, if you would have read the posts carefully and not only parts you can jump on, you would have seen, that the timeline object does not work fine for him, there is a gap of 1 second. That certainly is the reason for silent to try to help with hints, explanations and a cap file.

    I am no tutor, and I don't see, why I should act as one. You want the process of programming not to happen? Well, then you can't develop games. One does not happen without the other.

  • I made a timer example for the topic here

    hope this help you out.

  • You're attacking the wrong. We at least try to help - you don't.[quote:j195svmi]

    I didn't "attack" anyone. But the post was very condescending for no real reason. I guess you're unaware of it, maybe it wasn't on purpose. Nevertheless, the post was still condescending. He just assumed a bunch of things without knowing what he's talking about.

    > First of all, programming doesn't mean knowing C. Programming is a process of telling the computer, what you want him to do. You use whatever tools help you achieving this. C/C++/C#/Pascal/Basic/Construct/Flash/Python/lua ... you name it.

    >

    And that's the point. He condescended to him as if he doesn't know any of those without having any reason to assume it. Like I said, because a person asks a question about Construct doesn't mean they don't know anything about programming. That correlation is nonsensical. The post was condescending.

    > Second, whatever tool you choose, there is a core part that is shared among all of them. That is the basics you need to know, wether you like it or not.

    >

    That has nothing to do with the point. Like I said before, the steps and code for programming a Global variable in Construct is not the same in other programs or languages and that's a FACT, like it or not, and you know that fully well... and if you don't, you should.

    > Third, you need to have the wish to learn by doing.

    >

    So, if a person has guides, that's not learning by doing? Really? LOL. I guess we'd better throw out every school and University system on planet earth, lol! That doesn't even sound logical. It's just your opinion that people are supposed to fumble around aimlessly without guides, an opinion that appears to be widespread here, unfortunately.

    > Really, that post sounds so arrogant, like you want to sit in your chair, crossing your arms and telling everybody: "Now feed me." And while you are complaining, that help has to be done your way of thinking, because that certainly is the only right way, as noone is right but you - while moaning so, you do nothing of all that. Not one single code example from you, no cap file, no wiki entry, nothing.

    >

    Nonsense. The poster wants to sit there on his high horse like a know-it-all genius and tell people they don't know anything about programming because they asked a question about Construct. But actually, what you posted there is the way YOU come across and a lot of the other members here. It's YOUR way of thinking and no one else's matters. It's basically like many of you are saying, I know how to do everything already so let's look down on the new people for asking questions, even though asking questions makes perfect sense since the documentation is no good.

    You've created a closed old boys network and most of you are close-minded to new ideas. I could post various threads where people were attacked by long time members just for posting AN IDEA. The condescension of his post is typical.

    Secondly, how do you know I didn't send MrMiller a PM? Are you psychic? LOL.

    > I for one at least try to help, and btw I posted a link to an example cap file that covers all of it. So there is the visual example you're talking about, but I'm sure you don't know about it, because you hadn't have the time to revise it. Attacking the one's who are helping is much more important.

    >

    When I talked about the code examples, I was obviously talking about most of the posts (which I explained quite clearly). It's not my fault that you're having some reading comprehension trouble.

    > Last, if you would have read the posts carefully and not only parts you can jump on, you would have seen, that the timeline object does not work fine for him, there is a gap of 1 second. That certainly is the reason for silent to try to help with hints, explanations and a cap file.

    >

    > I am no tutor, and I don't see, why I should act as one. You want the process of programming not to happen? Well, then you can't develop games. One does not happen without the other.

    >

    I read that condescending post of carefully, don't you condescend to me. No one is asking for tutors. How is posting a code example being a tutor? Let's not be ridiculous.

    There are a number of factors as to why the count could be slow. It could be because of his system resources. It could be because game frames are high and it's slowing him down. Or, it could be an issue inherent to his setup. I've used the Timeline object and never had such a problem. So again, you're just assuming without knowing what you're talking about.

    I'm just pointing out a real issue. We seem to be blaming the new user as if he's the problem rather than the lack of instruction being the problem.

  • Whoa there guys, let's take a deeeeep breath

    Let me clear up a few things:

    1. I know what a global variable is, I just didn't know how to do it in Construct.

    2. I've programmed in Visual Basic and DarkBasic. I wouldn't call myself an expert by any stretch though. Programming in a language I'd say is far more difficult and time-consuming than using these types of programs. But that's why these programs are great, because it cuts down on that.

    3. The Time line object is okay for what I need. It doesn't have to be accurate to the millisecond because the timer I'm using is just a visual representation of an action happening in another layout. I wanted to know about the layout jumping for future reference but it's not applicable to my game now.

    4. My game is 90% done. It's a simple small game. I had to learn most of what I needed to do on my own which is perfectly fine, but some things I would've rather had a manual for. It's not a matter of wanting an easy way out or something, after all I've programmed in real languages and that can be really hard, so I'm not an easy-way-out guy. I just don't think manuals should even be looked at as easy way's out. Manuals are written for a reason; so that people can learn how to do something. Sure, you can always learn on your own, but normally when you do that you tend to not be as fundamentally sound as someone who learned "by the book" so to speak. Of course the upside may be that you may wind up more creative than the by-the-book guy and that can be a big plus, but that's another story.

  • Whoa there guys, let's take a deeeeep breath

    My post was an answer to the arrogance and ignorance of raymond and to noone else. I hope you didn't get this wrong, raymond just misused your thread, that's why my answer was posted here and not in discussion, where raymond's and my posts should be.

    But I learned a lot of Mr Almighty. Being helpful means you're condescending. Right. Understood.

  • Glad to hear you've worked things out, MrMiller. I hope my example was of some help, even so. I also hope that you weren't put off by my assumption that you were a complete beginner, as I didn't have much information to go on, and I'll usually respond as such if I think it's warranted. Make no mistake, it takes more time and effort on my part to go into more detail in explanations and commenting code, and pointing out resources. I trust that you know that I was simply trying to be helpful.

    I'd still recommend poking around with Python, just because I like it so much, and I think others might as well.

    I'm not by any means an expert either, but if you need any further help, feel free to ask (though I'd probably start a different thread...) Forums are a good place to pool information together from many sources, after all.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)