How to create game by using Timer??
satoshiwakata
Member, PRO Posts: 60
Dear Friends
Although I have made a game, I don't know what to do.
I want you to ask anyone.
Please look at the file. On blue actor, timer is working.
I want to record the time of the timer to Actor A by pressing the button.
Timer does not stop even if you press the button, the time of when you press the button will be recorded in the ActorA.
How Once I Will you be able to make it? ?
Comments
The device clock and the attributes game.Time, scene.Time, and self.Time are like real time. They don't stop. At least until someone builds a time machine. Because it's built-in, it's an easy thing to use but you can't change its value or stop it.
If you need a timer to count up and then stop or even reset, you'll need to build your own:
Timer Every 0.1 seconds
Change Attribute game.myTimer (real) to game.myTimer + 0.1
Or if you want to avoid a Timer behavior, just do this when you want to start (or reset) the custom timer:
Change Attribute game.startTime to game.Time
And then when you want to check the elapsed time:
Change Attribute game.elapsedTime to game.Time - game.startTime
You can do a similar strategy with the hours, minutes, seconds, etc. of the device clock but it will take a bit more work.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
A good flexible clock is a rotating actor, stick a little actor somewhere off camera, open its angular velocity attribute and enter '1'.
Now you have a little clock that accumulates 1°/sec, it's easy to read, easy to stop, restart, reverse, speed up, slow down (and so on . . . )
. . . . . . . . . . .
EDIT - there is a long standing bug with Angular Velocity and Rotation whereby values of 2 or below don't work, the actor will rotate to an angle of less than 1° and stop . . . so you'd need to either Constrain the actor's Angular Velocity to 1, or set the Angular Velocity / Rotation to something like 10, and take account of this x10 factor when using the numbers generated by the actor's rotation.
I like that idea, @Socks, except if you need to reference the value from other actors.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
That's petty much how I always use it ! I reference the actor's Rotation value from other actors.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Another way to generate a clock would be to say:
Constrain x to x+0.01666666666667
This will see x count up in 1 second increments, and again this is easy to start or stop, slow down, speed up, reverse (and so on).
I guess I'm "unlock averse."
The self-constrain is another interesting way to do this. Hmm...
How did you calculate that value?
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
I unlock already unlocked actors, that's how unlocky I am.
It's 1/60th/sec. Constrain = Do this once every code cycle. Code Cycle =1/60th/sec.
Thanks!
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Thank you. I try to do. If I have any problem, I will ask you in this board^^.