Clicks Per Second
CrumbyEntertainment
Member, PRO Posts: 32
Anyone know how we could display the number of clicks that is made in one second? We have two variables, "clicks" which registers how many clicks is made on the actor and then "CPS" which is suppose to show how many clicks per second there are.I feel like this is a very simple task I am just having a brain fart.
Comments
- Is there only 1 second allotted for clicking?
- Is this something like, average clicks per second?
If it's the former, the simplest way is to make use of a Timer (you can use GS' Timer, or you can make your own) and a custom Attribute to take note of clicks. Each time you click, increment the Attribute by 1 (e.g. Change Attribute: self.clicks to self.clicks + 1). After 1 second has passed, disable the Rule that increments, and voila. You can pass that value around your game however you please.
If it's the latter, you'll probably want to store each second's number of clicks inside a table (one cell for each). Afterwards, you just calculate for the Average of all the values. Oddly enough, I can't find a stock function inside the Expression Editor, so you will have to do this manually. You will also want to reset the number of clicks that you're keeping track of to zero every time a second has passed.
I'm still not sure how you want this to be though.
The more info you provide, the better we can help
So i know that a timer must be involved, also probably some sort of interpolation so that the number just doesn't go from 10 to 0 during that 2 second non clicking window.
i thought maybe that i could use a timer inside the "when actor is touched" rule and every .1 seconds or so set the Clicks per second to Total clicks and multiply by 10 (.1 seconds x 10 = 1 second) and display this value..But i know that this logic is flawed in some way, as is displayed by my output which only shows the total clicks value.
I worked for a few hours trying to get this and i just can't quite wrap my head around it...Any help at all would be glorious and greatly appreciated. I hope this made it a little more clear...
Rule: If touch is pressed
..Rule: If self.timerRunning = False
....Change Attribute: self.timerRunning = True
....Timer: After 1 second (run to completion)
......Change Attribute: self.CIS = 0
......Change Attribute: self.timerRunning = False
..Change Attribute: self.clicks = self.clicks + 1
..Change Attribute: self.CIS = self.CIS + 1
I'm on my phone so the dots represent nesting
Constrain attribute game.CPS to game.Clicks/game.Time
I know you said you wanted various complexities such as a 2-second delay. I didn't add that but I think the basic functionality works.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Kevincross, I tried what you suggested and it too did not work. I know this has to be possible, as it is not a complex task but something about the logic just hasn't clicked yet.
Im sure we will figure it out eventually.
Thanks for the help everyone.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User