Skip to main content
Tweeted twitter.com/#!/StackGameDev/status/88222398880555008
edited tags
Link
user744
user744
Source Link
dbomb101
  • 950
  • 1
  • 11
  • 26

Timer not going off

I've got a timer in my game which is supposed to set off a Boolean back to false after a certain amount of time has passed it just doesn't seem to work despite me trying to debug the issue, although setting off the timer works perfectly fine. Any help with this would be much appreciated

for (int i = 0; i < cameras.Count; ++i)
            {
                DetectCamera camera = cameras[i];
                Stopwatch camTimer = new Stopwatch();

                if (player.InterferenceStart && player.EMPBoundingCircle.Intersects(camera.BoundingRectangle))
                    camTimer.Start();

                if(camTimer.ElapsedMilliseconds >= 2000.0f)
                {
                    camera.CameraInRange = false;
                    camTimer.Reset();
                }
                else if (camTimer.IsRunning)
                    camera.CameraInRange = true;
            }