17
CO453 Application Programming Week 10 – animation .NET part 5

Week 10 NET part 5valerianweb.com/tutor/Assets/AyFd/CO453/Week 11 Unit 5 Animations.pdfMicrosoft PowerPoint - Week 10 NET part 5.pptx Author: derek Created Date: 3/22/2019 11:30:07

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Week 10 NET part 5valerianweb.com/tutor/Assets/AyFd/CO453/Week 11 Unit 5 Animations.pdfMicrosoft PowerPoint - Week 10 NET part 5.pptx Author: derek Created Date: 3/22/2019 11:30:07

CO453 Application Programming

Week 10 – animation.NET part 5

Page 2: Week 10 NET part 5valerianweb.com/tutor/Assets/AyFd/CO453/Week 11 Unit 5 Animations.pdfMicrosoft PowerPoint - Week 10 NET part 5.pptx Author: derek Created Date: 3/22/2019 11:30:07

How does an animation work?

Page 3: Week 10 NET part 5valerianweb.com/tutor/Assets/AyFd/CO453/Week 11 Unit 5 Animations.pdfMicrosoft PowerPoint - Week 10 NET part 5.pptx Author: derek Created Date: 3/22/2019 11:30:07

Simple Animation(using a

Timer control)

Page 4: Week 10 NET part 5valerianweb.com/tutor/Assets/AyFd/CO453/Week 11 Unit 5 Animations.pdfMicrosoft PowerPoint - Week 10 NET part 5.pptx Author: derek Created Date: 3/22/2019 11:30:07

Butterfly Animation

Page 5: Week 10 NET part 5valerianweb.com/tutor/Assets/AyFd/CO453/Week 11 Unit 5 Animations.pdfMicrosoft PowerPoint - Week 10 NET part 5.pptx Author: derek Created Date: 3/22/2019 11:30:07

There are 8 Butterfly Images

File Names: bfly0.gif, bfly1.gif up to bfly7.gif

Page 6: Week 10 NET part 5valerianweb.com/tutor/Assets/AyFd/CO453/Week 11 Unit 5 Animations.pdfMicrosoft PowerPoint - Week 10 NET part 5.pptx Author: derek Created Date: 3/22/2019 11:30:07

Using an Array to store the imagesconst int MAX = 8; // there are 8 imagesImage[ ] images = new Image[MAX]; // set up an image arrayconst int MAX = 8; // there are 8 imagesImage[ ] images = new Image[MAX]; // set up an image array

for(int i = 0; i < MAX; i++){

images[i] = Image.FromFile("bfly" + i +".gif");

}

for(int i = 0; i < MAX; i++){

images[i] = Image.FromFile("bfly" + i +".gif");

}

Put this codein the form’s

Load() method

images[ ] array

0

1

2

3

4

5

6

7

bfly0.gif

bfly1.gif

bfly2.gif

bfly3.gif

bfly4.gif

bfly5.gif

bfly6.gif

bfly7.gif

Page 7: Week 10 NET part 5valerianweb.com/tutor/Assets/AyFd/CO453/Week 11 Unit 5 Animations.pdfMicrosoft PowerPoint - Week 10 NET part 5.pptx Author: derek Created Date: 3/22/2019 11:30:07

Display images in the PictureBox

images[ ] array

0 bfly0.gif

1 bfly1.gif

2 bfly2.gif

3 bfly3.gif

4 bfly4.gif

5 bfly5.gif

6 bfly6.gif

7 bfly7.gif

pbxBFly.Image = images[count];count ++;pbxBFly.Image = images[count];count ++;

Put this code in thetimer’s Tick() method

Page 8: Week 10 NET part 5valerianweb.com/tutor/Assets/AyFd/CO453/Week 11 Unit 5 Animations.pdfMicrosoft PowerPoint - Week 10 NET part 5.pptx Author: derek Created Date: 3/22/2019 11:30:07

Activity

Code exercise 5.1 to make the butterfly animate when the timer is started

Page 9: Week 10 NET part 5valerianweb.com/tutor/Assets/AyFd/CO453/Week 11 Unit 5 Animations.pdfMicrosoft PowerPoint - Week 10 NET part 5.pptx Author: derek Created Date: 3/22/2019 11:30:07

Date and Time(using a Timer control)

Page 10: Week 10 NET part 5valerianweb.com/tutor/Assets/AyFd/CO453/Week 11 Unit 5 Animations.pdfMicrosoft PowerPoint - Week 10 NET part 5.pptx Author: derek Created Date: 3/22/2019 11:30:07

Using a Timer Control with a Time and Date Display

2 Labels in a Panel Container

2 Labels in a Panel Container

Page 11: Week 10 NET part 5valerianweb.com/tutor/Assets/AyFd/CO453/Week 11 Unit 5 Animations.pdfMicrosoft PowerPoint - Week 10 NET part 5.pptx Author: derek Created Date: 3/22/2019 11:30:07

Activity

Code exercise 5.2 to update the time display

Page 12: Week 10 NET part 5valerianweb.com/tutor/Assets/AyFd/CO453/Week 11 Unit 5 Animations.pdfMicrosoft PowerPoint - Week 10 NET part 5.pptx Author: derek Created Date: 3/22/2019 11:30:07

Moving an Image(using a Timer again)

Page 13: Week 10 NET part 5valerianweb.com/tutor/Assets/AyFd/CO453/Week 11 Unit 5 Animations.pdfMicrosoft PowerPoint - Week 10 NET part 5.pptx Author: derek Created Date: 3/22/2019 11:30:07

Move a PictureBox down screen

pbxSealpbxSeal

btnStartbtnStart

btnStopbtnStop

btnQuitbtnQuit

timer1timer1

Page 14: Week 10 NET part 5valerianweb.com/tutor/Assets/AyFd/CO453/Week 11 Unit 5 Animations.pdfMicrosoft PowerPoint - Week 10 NET part 5.pptx Author: derek Created Date: 3/22/2019 11:30:07

A note on Graphics Coordinates

this.Width

this.Height

pbxSeal.Top

pbxSeal.Height

pbxSeal.Width

pbxSeal.Bottom

pbxSeal.Left pbxSeal.Right

Note: Objects have a Top, Bottom, Left, Right, Width, HeightCoordinates start from 0,0 at the top left corner

Note: Objects have a Top, Bottom, Left, Right, Width, HeightCoordinates start from 0,0 at the top left corner

Page 15: Week 10 NET part 5valerianweb.com/tutor/Assets/AyFd/CO453/Week 11 Unit 5 Animations.pdfMicrosoft PowerPoint - Week 10 NET part 5.pptx Author: derek Created Date: 3/22/2019 11:30:07

Code for the Timer Project

Page 16: Week 10 NET part 5valerianweb.com/tutor/Assets/AyFd/CO453/Week 11 Unit 5 Animations.pdfMicrosoft PowerPoint - Week 10 NET part 5.pptx Author: derek Created Date: 3/22/2019 11:30:07

Activity

Code exercise 5.3 to make the helicopter animate

Page 17: Week 10 NET part 5valerianweb.com/tutor/Assets/AyFd/CO453/Week 11 Unit 5 Animations.pdfMicrosoft PowerPoint - Week 10 NET part 5.pptx Author: derek Created Date: 3/22/2019 11:30:07

The Last Slide