• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Smarter NSTimer?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Smarter NSTimer?


  • Subject: Re: Smarter NSTimer?
  • From: Alex Zavatone <email@hidden>
  • Date: Tue, 01 Jul 2014 14:59:30 -0400

How about keeping track of the amount of time paused and the remaining time on the timer is a function of the next interval - the elapsed paused time?

Seems like an overly simple proposal, but would that work if?

On Jul 1, 2014, at 2:21 PM, William Squires wrote:

>  What would be the best way to make an NSTimer that could pause/un-pause its timing? Subclassing? Containment? Just roll my own with performWithSelector:afterDelay:? That is, if I (my code) creates a (smart) NSTimer with a duration of 5 seconds, then three seconds later I need to pause the timer, the timer should un-pause with 2 seconds left on it, not revert back to a duration of 5 seconds.
>
> Use-case:
>  I have a (fictitious) FPS game in which the players or bots can "damage" the scenery by leaving blast marks. A timer should remove these "decorations" after a given delay, but I want the timers to pause if any players/bots are within line-of-sight of the decorations. The timer should then un-pause once all the players and bots are out of line-of-sight (self-repairing nanotech scenery, anyone?)
>  With a normal timer, you'd have to [<timer> invalidate], and/or re-create a new NSTimer instance, which would reset the time.
>  Another good use is a "smartly" timed weapon/power-up spawn point. If the player (or a bot) is too close, the timer will pause, preventing the spawning of the weapons/power-ups, but as soon as no players or bots are close by, the timer will resume, and a new weapon or power-up will spawn there. This would discourage "camping" around known spawn points! :)
>
> Or has this "wheel" already been invented?
>
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


References: 
 >Smarter NSTimer? (From: William Squires <email@hidden>)

  • Prev by Date: Re: Smarter NSTimer?
  • Next by Date: Re: Smarter NSTimer?
  • Previous by thread: Re: Smarter NSTimer?
  • Next by thread: Re: Smarter NSTimer?
  • Index(es):
    • Date
    • Thread