{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Lec19 - Lecture 19 Timers Animation PIC 10C Todd Wittman...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Lecture 19: Timers & Animation PIC 10C Todd Wittman Threading square6 Blocks of code that run concurrently with the main program are called threads . square6 Programming these blocks so that all the pieces of the program work together is called threading . square6 One example of threading is to have a procedure that executes at set time intervals. square6 This could be useful for animations -- we would draw a new image frame every interval.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
2 Timer square6 The Timer control is like a stopwatch that allows you to keep track of time as your program runs. square6 There aren't many properties for the Timer. square6 Enabled -- true if you want the clock to be running square6 GenerateMember -- whether you want it to generate an object square6 Interval -- how often you want the Tick() event to occur. Default is 100 milliseconds. Timer square6 The important functions are: square6 timer.Start() -- start the clock running (Enabled=true) square6 timer.Stop() -- stop the clock (Enabled=false) square6 Note by default the Timer is disabled, so you have to tell it when to Start. square6 The Tick() event of the Timer is fired every time an Interval elapses. square6 For example, to animate a picture we would draw in Tick(). private void animationTimer_Tick(object sender, EventArgs e) { Move objects a little bit g.DrawStuff(); this.Refresh(); }
Background image of page 2
3 Example: Moving in Circles square6 Ex Animate a rectangle so that it moves around in a circle.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}