Programming games Flash concepts. Coin toss. Filezilla: upload your project(s) Homework: Enjoy...

27
Programming games Flash concepts. Coin toss. Filezilla: upload your project(s) Homework: Enjoy Spring Break.

Transcript of Programming games Flash concepts. Coin toss. Filezilla: upload your project(s) Homework: Enjoy...

Page 1: Programming games Flash concepts. Coin toss. Filezilla: upload your project(s) Homework: Enjoy Spring Break.

Programming games

Flash concepts. Coin toss.Filezilla: upload your project(s)

Homework: Enjoy Spring Break.

Page 2: Programming games Flash concepts. Coin toss. Filezilla: upload your project(s) Homework: Enjoy Spring Break.

Flash

• Environment for creating and testing Flash application– including writing code and creating graphics

• When you are done, you PUBLISH to produce a pair of files: .swf and .html.

• Many features in Flash: more than we will do.

Page 3: Programming games Flash concepts. Coin toss. Filezilla: upload your project(s) Homework: Enjoy Spring Break.
Page 4: Programming games Flash concepts. Coin toss. Filezilla: upload your project(s) Homework: Enjoy Spring Break.

ActionScript 3.0.

• We will NOT do ActionScript 2.0.• Significant changes in the language.

Page 5: Programming games Flash concepts. Coin toss. Filezilla: upload your project(s) Homework: Enjoy Spring Break.

Flash features

• Stage• Timeline

– frames– layers

• Properties panel• Tool panel

• Window/Actions: where you write code for a layer of a frame in a timeline.

Page 6: Programming games Flash concepts. Coin toss. Filezilla: upload your project(s) Homework: Enjoy Spring Break.
Page 7: Programming games Flash concepts. Coin toss. Filezilla: upload your project(s) Homework: Enjoy Spring Break.

Flash object• Movie clip

– Timeline: 1 to any number of frames– code in any frame– Note: many of our movie clip symbols will have just

one frame.• Button

– 4 frames: up, over, down, hit• Graphics• We mainly will create movie clip symbols and

place instances of them on the Stage at specific frames.

Page 8: Programming games Flash concepts. Coin toss. Filezilla: upload your project(s) Homework: Enjoy Spring Break.

Coin toss• Create 2 movie clip symbols and move instances to the

Stage and NAME INSTANCES.– head– tail

• Look at Window/common libraries/buttons and get a button– alter this button to display FLIP.– name the button instance

• Write code in the [only] frame of the main movie (Scene 1) to – set up event handling for hitting the button– simulating random coin toss by making either head or tail visible

and the other not visible.

Page 9: Programming games Flash concepts. Coin toss. Filezilla: upload your project(s) Homework: Enjoy Spring Break.
Page 10: Programming games Flash concepts. Coin toss. Filezilla: upload your project(s) Homework: Enjoy Spring Break.

Techniques

• Use rectangle/oval tool and keep shift key down to make a circle.

• In Library panel, right click on head, duplicate, rename tail to get same size.

• Use segmentation to erase parts…• Change magnification to make larger to

ease drawing.

Page 11: Programming games Flash concepts. Coin toss. Filezilla: upload your project(s) Homework: Enjoy Spring Break.
Page 12: Programming games Flash concepts. Coin toss. Filezilla: upload your project(s) Homework: Enjoy Spring Break.

NAME things

• Move instances of symbols to Stage.• You need to give the instances names in

order to reference them in ActionScript.

• While selected, in Properties panel, give a name.– It can be the same as the movie clip symbol

name. In some applications, you may have more than one.

Page 13: Programming games Flash concepts. Coin toss. Filezilla: upload your project(s) Homework: Enjoy Spring Break.
Page 14: Programming games Flash concepts. Coin toss. Filezilla: upload your project(s) Homework: Enjoy Spring Break.
Page 15: Programming games Flash concepts. Coin toss. Filezilla: upload your project(s) Homework: Enjoy Spring Break.

Buttons

• I will show you 3 ways to make buttons. – common library– do it yourself (rock paper scissors)– components

• This is Common Library way. Need to change Enter to Flip.

Page 16: Programming games Flash concepts. Coin toss. Filezilla: upload your project(s) Homework: Enjoy Spring Break.

Change symbol in Library

Page 17: Programming games Flash concepts. Coin toss. Filezilla: upload your project(s) Homework: Enjoy Spring Break.

Changing text…• Need to unlock the text layer• Pick up T tool • make change

• return to Scene 1

Page 18: Programming games Flash concepts. Coin toss. Filezilla: upload your project(s) Homework: Enjoy Spring Break.

Notice

• When you change something in the Library, all instances of it change on the Stage.

• Need to give the button instance on Stage a name: flipbtn.

Page 19: Programming games Flash concepts. Coin toss. Filezilla: upload your project(s) Homework: Enjoy Spring Break.
Page 20: Programming games Flash concepts. Coin toss. Filezilla: upload your project(s) Homework: Enjoy Spring Break.

Add coding

• Click off of any object so nothing is selected.

• Windows/Actions• Write code

Page 21: Programming games Flash concepts. Coin toss. Filezilla: upload your project(s) Homework: Enjoy Spring Break.
Page 22: Programming games Flash concepts. Coin toss. Filezilla: upload your project(s) Homework: Enjoy Spring Break.

Testing

• Go to Control/Test movie/In Flash Professional

• When it works, File/Save As

Page 23: Programming games Flash concepts. Coin toss. Filezilla: upload your project(s) Homework: Enjoy Spring Break.

Improvement

• Keep track of counts of heads and tails.• Create 2 TLF read only and 2 selectable

text fields• Expand Character panel to change size

and font and other features.• Use x and y in Properties panel to line up.• Name the selectable text fields.• Modify code.

Page 24: Programming games Flash concepts. Coin toss. Filezilla: upload your project(s) Homework: Enjoy Spring Break.

2 + 2 text fields

Page 25: Programming games Flash concepts. Coin toss. Filezilla: upload your project(s) Homework: Enjoy Spring Break.

Changing code

• The text in the text field must be changed to a number before adding 1 to it and then changed back to text.

• The text is referenced using the name of the text field with .text

Page 26: Programming games Flash concepts. Coin toss. Filezilla: upload your project(s) Homework: Enjoy Spring Break.
Page 27: Programming games Flash concepts. Coin toss. Filezilla: upload your project(s) Homework: Enjoy Spring Break.

Homework

• [Finish and show coin toss with counts. Add anything else you want.]

• Enjoy break!

• You can do tutorials, practice drawing.• You can look ahead to rock-paper-

scissors, Bo the barking dog, etc.