Programming games - PowerPoint PPT Presentation

1 / 22
About This Presentation
Title:

Programming games

Description:

Note: in most situations, Flash is not this particular... Adobe Flash Media Encoder can take in various file types and produce .flv ... – PowerPoint PPT presentation

Number of Views:40
Avg rating:3.0/5.0
Slides: 23
Provided by: Jeanin
Category:

less

Transcript and Presenter's Notes

Title: Programming games


1
Programming games
  • Reminders
  • Sound and Video
  • Grabber feature
  • Health bar timer
  • General comments adding to a project
  • Homework Finish work!

2
Jigsaw location of files
  • Note in most situations, Flash is not this
    particular
  • Name your .fla file something other than jigsaw.
    I named mine lizard.
  • Save the .fla file on drive
  • Create on that same drive, at the top of the
    drive a as3 folder.
  • In the as3 folder, create a folder named jigsaw
  • In the jigsaw folder, save Piece.as

3
Other FLASH applications with external as files
  • For example, shooter
  • Save the .fla file on a drive
  • In that same drive, at the top,create a folder
    as3
  • In that as3 folder, create a folder with the name
    of the package
  • In that folder, save all the class files.

4
Uploading
  • You can use your newmedia.purchase.edu as a place
    to store your .fla and .as files
  • HOWEVER
  • To upload to show your work to the world, you
    File/Publish and upload the .html and the .swf
    files only.
  • PLUS you also need to upload the
    fileAC_RunActiveContent.js. It is produced when
    you publish an application.

5
Runtime files
  • Basic applications INCLUDING those with .as
    filesupload .html and .swf
  • Applications using video and sound (accessed
    using FLVPlayback and Sound objects)also need to
    upload the .flv and .mpg files OR use full URL
    for their location

6
Video and sound
  • Need to acquire the video clip and the sound
  • Adobe Flash Media Encoder can take in various
    file types and produce .flv
  • For Sound, need to find editors/encoders
  • Flash can handle other types for certain
    functions
  • As with images, it makes sense to use other tools
    to get the image/video/sound you want

7
Video and Sound
  • Can incorporate sounds into frames
  • OR
  • var urlnameString "missle.mp3"
  • var requestsfURLRequest new URLRequest(urlname)
  • var msoundSound new Sound(requestsf)
  • // at appropriate place in the code
  • msound.play()
  • Can incorporate video into frames
  • OR
  • var flvFLVPlayback new FLVPlayback()
  • flv.source "dickey2.flv"
  • flv.x 10
  • flv.y 10
  • //at appropriate place
  • addChild(flv)//
  • // alsoflv.play()

8
Placement
  • REMEMBER
  • the origin of a symbol in the Library is what is
    positioned by the code.
  • The transformation point is the point of
    rotation.
  • You can manually change scale, angle, etc., but
    be clear on what you are doing

9
Caution
  • If you are combining coding and material from
    different (old) programs, be careful on names.
    Each thing needs its unique name
  • Example
  • ball from bouncing ball vs ball from cannonball
  • Timers

10
Caution
  • Case (upper case versus lower case) matters
    within Flash and ActionScript
  • And
  • Case matters on newmedia.purchase.edu server

11
Grabber
  • also called idler, attractor,
  • Animation to attract attention to a kiosk type
    application
  • Person/player comes up and does something,
    typically move mouse, that initiates actual
    application
  • Idler re-starts if and when system is idle
  • detecting state of being idle is not obvious

12
Jigsaw
  • The idler/grabber animation does relate to real
    application.
  • Real application starts when mouse is moved
  • Idler resumes
  • after game is started, but no move made
  • after completed puzzle
  • after a long time between moves

13
Technique for timing
  • Use 2 Timer objects
  • Control starting and stopping
  • Essentially when something happens, stop and then
    re-start Timer
  • This is like advancing your alarm clock if you
    wake up early, but now want to sleep longer.

14
Add a health bar
  • Needed
  • bar that visibly shrinks over time
  • when bar is gone (or close), end game
  • Solution
  • Create bar symbol in Library and use Linkage to
    link it to a class
  • Create a single Bar instance dynamically
  • Grow and shrink using methods called from methods
    in other classes

15
Notes on jigsaw
  • You need to bring instances of each piece to the
    Stage and name the instances
  • piece1, piece2, etc.
  • You do NOT have to reconstruct the puzzle on the
    Stage.

16
Notes on jigsaw, others
  • Be sure to use the ActionScript 3.0 tutorials
  • NOTE the separation of coding into two files
    makes it much easier to do other jigsaws.
  • The Piece.as file is the same
  • The .fla file has the pieces!

17
Note
  • You can use other/better names for the buttons
  • The button that invokes the function mixup could
    hold the text PLAY

18
Debugging
  • Can use trace statements to indicate where the
    code is
  • Values of variables, properties.
  • REMOVE this code
  • Can remove it using //

19
Jigsaw
  • Early version of program has 3 buttons, calling
    functions, mixup, check and build.
  • Better version is to remove the check button and
    put in a call to check after each move.
  • Remember the code is doing the work, not you!

20
Reflection
  • It is beneficial to reflect on why something is
    more complicated.
  • In cannonball, angle
  • Text in input text field
  • Need a way to save value to make sure all frames
    have the up to date value
  • Need to convert text to number
  • Need to convert original angle (degrees) to
    radians

21
Adding to existing project
  • May need to add labels and change gotoAndPlay
    functions to refer to labels
  • May need to insert frames
  • Insert frame
  • right click and Convert to Key Frame
  • Copy and paste-in-place
  • may need to repeat for successive frames
  • Symbols in Library are copied over.
  • Watch out for use of same names!

22
Homework
  • Finish projects
  • Do your final ActionScript Project. Post proposal
    for my approval, comments suggestions.
  • Note many of the examples and explanations
    (Notes, Tutorials) were done in response to
    requests.
  • Latest sending email from Flash (using php
    program on the server). See variant of Chasing
    Bo.
  • Review lecture notes and guide to final quiz
Write a Comment
User Comments (0)
About PowerShow.com