Top Banner
Programming games Cannonball due. Drawing & printing example. Acquiring video or sound Homework: Catch up: complete projects (rps, Bo, cb). Start video or audio. Plan your project.
23

Programming games

Jan 22, 2016

Download

Documents

ahanu

Programming games. Cannonball due. Drawing & printing example. Acquiring video or sound Homework: Catch up: complete projects (rps, Bo, cb). Start video or audio. Plan your project. Cannonball extension. You may consider adding sound to cannonball for your sound/video project. Can use - PowerPoint PPT Presentation
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Programming games

Programming games

Cannonball due. Drawing & printing example.

Acquiring video or soundHomework: Catch up: complete

projects (rps, Bo, cb). Start video or audio. Plan your project.

Page 2: Programming games

Cannonball extension

• You may consider adding sound to cannonball for your sound/video project.

• Can use– coding or– sound in frame

Page 3: Programming games

Flash terms

• Create .fla and .as files using Flash development environment. This is development time.

• Runtime (aka execution time)– Test program using the development

environment. This does create a .swf file.– Publish creates .html file and .swf file

Page 4: Programming games

Development time

• Bring instances of movie clip symbols in Library to the Stage.– Give instance names– ActionScript refers to instances by name

• Can File/Print– May not do what you want…– I copy and paste code into Word or

Dreamweaver

Page 5: Programming games

Drawing & printing

• Adding content, namely a movie clip symbol to Stage at runtime– Various calculations– Use Properties of symbol (right mouse click)

to set up: Export for ActionScript

• Print during runtime– Can set up to print several pages. My

example just prints one page.

Page 6: Programming games

Demonstrate

• Drawing example

• Note: this is a ‘stub’ for a bigger application.

Page 7: Programming games

Features

• Create wall symbol. Change settings to Export for ActionScript.

• Set up handling for mouse click on board.– One handler for 1st click and another for 2nd

click– Use ev.localX and ev.localY to get

coordinates.– Use Math.atan2(…) and Point.distance(…)

• Use PrintJob

Page 8: Programming games

Making your own video for Flash playback

• Shoot video

• Upload to computer

• [Edit]

• Produce .flv

• Create Flash movie and test

• Publish Flash movie– Upload .html, .swf, and all the .flv files to the

server

Page 9: Programming games

Initial steps

• Shoot (?) video

• Upload to computer

Page 10: Programming games

Producing .flv

• Just like images, there are different encodings for videos.– wmv, mov, avi, dv, ….

• Adobe Flash CS4 Media Encoder will accept many different types and produce an .flv file (an .flv version of the same video clip)– Can set quality settings

• Tradeoff: size (space on server, loading time) versus quality

Page 11: Programming games
Page 12: Programming games
Page 13: Programming games
Page 14: Programming games

Start queue

• Creating the .flv file takes a while….

• You can do more than one encoding at a time.– The name of each file is the same name, with

filetype .flv

• Use the pre-set settings OR get into more detail– Higher quality means larger files

Page 15: Programming games
Page 16: Programming games

Acquire video

• Find website with video (or audio)

• go to http://file2hd.com/– Enter URL of site– Check off agree to terms, filter (movies or

audio)– click on get files– be patient– choose from list.

Page 17: Programming games

SoundTwo (at least) methods for incorporating

sound into Flash

• All coding: create Sound objects, set source of sound, play. Can manipulate volume, pan, etc. using Soundchannel. Also, register and handle events, including when sound has been loaded.

• Frame: associate [start of] sound with frame.

Page 18: Programming games

Acquire sound

• Many types of sound. For coding method, need mp3

• Find on-line sound editors.

• Need to know location (URL) of sound file(s).

Page 19: Programming games

Coding method

import flash.media.Sound;import flash.net.URLRequest;

var urlname:String = "missle.mp3";var requestsf:URLRequest = new

URLRequest(urlname);var msound:Sound = new Sound(requestsf);

// at appropriate place in the codemsound.play();

This file is located in the same folder on my computer. It doesn't have to be.

Page 20: Programming games

Frame method

• File/Import/Import to Library– Select sound file(s).

• Click on appropriate frame in timeline

• In property panel, select Sound [file].– You can select a set effect and/or edit the

sound.

Page 21: Programming games

Cautions

• In either method, need to be aware that sound lasts certain amount of time.

• Be careful about starting sound again and again (unless that is what you want)

Page 22: Programming games

Examine source

• Sound added to frame– Bo the barking dog – consider for collapsing/exploding target

• Code– Play sound as event handler for button click– Play random choice of tune from [short] list.

• Note: pause, pan, volume features. These require other objects.

Page 23: Programming games

Homework

• Decide on video or audio– Create or acquire video clip(s)– Create or acquire audio clips. Can use Common

Library / sounds.– Keep in mind: this is a short assignment.– You can incorporate sound or video into your final

project.

• Think about what you want to do for your project– Check with me AND make proposal to blog.