Recent

Author Topic: [solved] "resetting" ttimer  (Read 553 times)

speter

  • Hero Member
  • *****
  • Posts: 532
[solved] "resetting" ttimer
« on: March 30, 2026, 02:56:31 am »
I am writing a game which uses a timer. I want to move the player if they don't move within the timer's interval; but when they do move, I want to "reset" the timer.

I think the simplest way would be to set timer.interval and timer.enabled; then if the player does a move, I would set timer.enabled := false; then timer.enabled := true; - is this sensible?

Alternatively, should I use timer.killtimer?

cheers
S.
« Last Edit: March 30, 2026, 04:25:29 am by speter »
I climbed mighty mountains, and saw that they were actually tiny foothills. :)

speter

  • Hero Member
  • *****
  • Posts: 532
Re: "resetting" ttimer
« Reply #1 on: March 30, 2026, 04:25:04 am »
using .enabled seems to work fine.
I climbed mighty mountains, and saw that they were actually tiny foothills. :)

Thaddy

  • Hero Member
  • *****
  • Posts: 19268
  • Glad to be alive.
Re: [solved] "resetting" ttimer
« Reply #2 on: March 30, 2026, 05:43:30 am »
timer.enabled := not timer.enabled is a quicker way to have false/true.
objects are fine constructs. You can even initialize them with constructors.

speter

  • Hero Member
  • *****
  • Posts: 532
Re: [solved] "resetting" ttimer
« Reply #3 on: March 30, 2026, 06:05:38 am »
timer.enabled := not timer.enabled is a quicker way to have false/true.
Thanks Thaddy.
I climbed mighty mountains, and saw that they were actually tiny foothills. :)

 

TinyPortal © 2005-2018