Programming games - PowerPoint PPT Presentation

1 / 14
About This Presentation
Title:

Programming games

Description:

flv.source = 'dickey2.flv'; // my video. flv.x = 10; //position horizontally ... Be careful and systematic about recording the x and y information. Classwork/Homework ... – PowerPoint PPT presentation

Number of Views:42
Avg rating:3.0/5.0
Slides: 15
Provided by: Jeanin
Category:

less

Transcript and Presenter's Notes

Title: Programming games


1
Programming games
  • Chasing Bo. Recap Video
  • Homework Finish base projects. Post proposal on
    Flash project. Work on project(s)!

2
Chasing Bo
  • Added two events
  • bo.addEventListener(MouseEvent.MOUSE_OVER,
    changedirection)
  • bo.addEventListener(MouseEvent.CLICK,stopbo)

3
Video examples
  • Simple play video 'in' Flash
  • Play choice of videos
  • For larger archive of video clips, use database
    to determine which one to play
  • Webcam example

4
Cautions on video
  • FLVPlayback is a type of object built-in to
    Flash.
  • BUT you need to import the definitions
  • import fl.video.
  • or give a long name.
  • You need to get the FLVPlayback Symbol in the
    Library, even though the code creates an instance
    and places it on the Stage
  • Your code needs to add the newly created object
    to the display list.
  • See tutorials.

5
Get FLVPlayback in the .fla file
  • Window/Components/FLVPlayback
  • Move to Stage and erase or move straight to
    Library

6
Frame code
  • import fl.video.
  • var flvFLVPlayback //declare flv
  • flv new FLVPlayback() //initialize it
  • flv.source "dickey2.flv" // my video
  • flv.x 10 //position horizontally
  • flv.y 10 // . vertically
  • addChild(flv) // display it!!!

7
Play choice of videos
  • First example plays that one video immediately.
  • Critical assignment was flv.source
    "dickey2.flv"
  • For choice of videos need to determine name of
    video from the button pushed

8
Using event data
  • Recall the functions that are cited in
    addEventListener all have a parameter.
  • My previous examples did not use the parameter in
    the function!
  • For the video playing example, make both buttons
    point to same function
  • playbtn0.addEventListener(MouseEvent.CLICK,playit)

  • playbtn1.addEventListener(MouseEvent.CLICK,playit)

  • How to determine which button was pressed?

9
Using event data
  • Make the event handler function use the event
    parameter passed to it
  • ev.target.name is the name of the button.
  • I know that the 7th character of the name is
    either 0 or 1.
  • I set up an array of the clips

10
Coding
  • var clipsArray
  • "dickeybrook.flv",
  • "sumo.flv"
  • function playit(evEvent)
  • var clipnameclipsparseInt(ev.target.name.subst
    r(7,1))
  • flv.source clipname

11
Function arguments
  • function playthisvideo(vnString)
  • .
  • flv.src vn
  • .
  • playthisvideo("dickeybrook.flv")
  • Or choice "sumo.flv"
  • playthisvideo(choice)

This puts sets the src to be whatever the
parameter vn holds
12
Other examples
  • Use php on server to access MySql database for
    information on clips
  • Use calculation on webcam input to determine
    which recorded video to playback
  • Read tutorials
  • Come see me.

13
Jigsaw variations
  • Read the whole tutorial.
  • Pay attention to the location of the .as files.
  • Be careful and systematic about recording the x
    and y information

14
Classwork/Homework
  • (Finish base projects rps, bouncing ball,
    cannonball, video)
  • Decide on Flash project
  • Make posting
  • Work on project.
  • have something to test often
Write a Comment
User Comments (0)
About PowerShow.com