Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
GameProgram

spaceinvaders
Class GameProgram

java.lang.Object  spaceinvaders.GameProgram

public class GameProgram
extends java.lang.Object

Driver program for the SpaceInvaders demonstration of "framework" code and inheritance hierarchy.


Constructor Summary
()
           
 
Method Summary
static java.awt.Image(java.lang.String name)
          Returns an Image object with data loaded from a file in the "user directory" (typically the directory where the Java .class file is located) Pauses the program until image is loaded.
static java.applet.AudioClip(java.lang.String name)
          Loads a sound file (see main Java documentation for supported sound formats) File should be in "user directory".
static void(java.lang.String[] args)
          Main function.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GameProgram

public GameProgram()
Method Detail

getImage

public static java.awt.Image getImage(java.lang.String name)
Returns an Image object with data loaded from a file in the "user directory" (typically the directory where the Java .class file is located) Pauses the program until image is loaded.

Parameters:
name - Name of file with image
Returns:
Image object

getSound

public static java.applet.AudioClip getSound(java.lang.String name)
Loads a sound file (see main Java documentation for supported sound formats) File should be in "user directory". Terminates program if get error input.

Parameters:
name - Name of file with sound
Returns:
AudioClip object

main

public static void main(java.lang.String[] args)
Main function. Creates a JFrame to hold the display and deals with window closing events. Creates the main Game object. (You might want to edit the argument to Game constructor - this argument defines the number of invaders that are to be attacking. Could be increased for faster machines and better players, decreased for slower machines.) Creates the display elements, links things up, leaves program running in graphics thread.

Parameters:
args - No command line arguments used