1 / 16

Programming Games

Programming Games. Preview Video & Audio. Work on cannonball. Homework: finish cannonball!. Video in Flash. More than one way to incorporate video into Flash bring in whole video that plays along with the frames. We will not use this way! For this class, we will use a FLVPlayback object

fordon
Download Presentation

Programming Games

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Programming Games Preview Video & Audio. Work on cannonball. Homework: finish cannonball!

  2. Video in Flash More than one way to incorporate video into Flash bring in whole video that plays along with the frames. We will not use this way! For this class, we will use a FLVPlayback object Requires an import statement This allows shorthand names for built-in parts of ActionScript Requires statement adding to Display list Objects created in code (as opposed to put directly on the Stage) need to be added to the Display list to be shown.

  3. Videos Different types of videos (like different types of images) Flash video playback requires videos of type .flv Can use Adobe Flash Media Encoder (part of the Adobe CS5 package) to take one type of video and produce an flv

  4. Basic coding import fl.video.*; //get the builtin classes var flv:FLVPlayback; //set up variable flv = new FLVPlayback(); //give it a value flv.source= "dickey2.flv"; //set source attribute flv.x = 10; //position on screen horizontally flv.y = 10; // and vertically addChild(flv); // make visible by adding to // Display list

  5. addChild Adds to the Display list. In my tutorials, you also will seecanvass.addChild(stuff); This adds the newly created stuff object as a child of canvass. This will determine the positioning of stuff.

  6. Skins These are the video clip controls. Appropriate when you want to give the player/user/customer more controls You may choose NOT to give user control in certain cases Many choices USE HELP! Requires you to upload an .swf file to the server.

  7. Files for your application • Your application will consist of the following files. Say your application is called mywork.fla • mywork.html • mywork.swf • For each video: f1.flv, f2.flv, etc. The names f1, f2, need to be replaced by the names you gave the video. (Remember: no blanks!) • For each skin: the name of the skin file: xxxx.swf

  8. Video examples • Play back single video • Play back choice of video (two ways) • Bouncing Ball • Used mask to make the playback a circle • Jigsaw puzzle turning into video • This can be your final project, not this 1 week assignment. • ???

  9. Video Use camera Need to upload If not .flv, use Flash Media encoder to made an .flv Use http://file2hd.com/ (or other sites) to download video from YouTube Note: I prefer you to use your own. If you use someone else's, you must make 'value-add' to the project.

  10. Audio • The name of the Flash object is Sound. The object for video is FLVPlayback. So I tend to say video and sound…. • Two ways for including audio • associate with a frame • See Bo the Barking Dog. • use code • to get the sound file • to set a Sound object • to start and stop and….

  11. Sample sound code could be any URL import flash.media.Sound; import flash.net.URLRequest; var req:URLRequest=new URLRequest("missle.mp3"); var msound:Sound=new Sound(); msound.load(req); function playsound(event) { msound.play(); } playbtn.addEventListener(MouseEvent.CLICK,playsound);

  12. Reprise: Cannonball • Mixture of computed and cel animation. • Caution: angle • set in editable/input text field as text, • code calculates number representing degrees, and • code calculates number representing radians. • Must test (and keep testing) ball missing target (in front and over…) and hitting target. • Collisions • hitTestPoint: origin of ball versus occupied pixels of target. • Check of ball.y > (further down screen) of ground.y.

  13. Collision detection alternatives • a.hitTestObject(b) checks for intersection of bounding boxes around a and b. • compose target of multiple distinct objects and do hitTestPoint versus each one. • Can calculate points intersecting circles: is distance from point to center of circle less than radius.

  14. distance function function distance(px,py,qx,qy) { var xd = px-qx; var yd = py-qy; var dsquared = xd*xd+yd*yd; return (Math.sqrt(dsquared)); }

  15. Phases • Doing projects in phases is the way to go… • Any division of work is better than trying to do the whole thing before testing. • …

  16. Homework • Complete cannonball. • Start planning sound or video project.

More Related