From FANG
null
|
01 packagepackage is used to name the directory or folder a class is in examples.sprites;
02 //start auto-imports
03 //end auto-imports
04
05 importimport means to make the classes and/or packages available in this program fang2.core.*;
06 importimport means to make the classes and/or packages available in this program fang2.sprites.*;
07 importimport means to make the classes and/or packages available in this program fang2.transformers.*;
08 importimport means to make the classes and/or packages available in this program fang2.attributes.*;
09 importimport means to make the classes and/or packages available in this program java.awt.*;
10 importimport means to make the classes and/or packages available in this program java.awt.geom.*;
11
12 /**
13 * This Example displays an ImageSprite on the screen.
14 * @authorthis is the Javadoc tag for documenting who created the source code Alan Davis
15 */
16 publicpublic is used to indicate unrestricted access (any other class can have access) classclass is a group of fields and methods used for making objects ImageSpriteExample extendsextends means to customize or extend the functionality of a class Game
17 {open braces start code blocks and must be matched with a close brace
18 /**Here we are declaring our sprite named dude*/
19 Sprite dude;
20
21 /**sets up the game*/
22 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value setup()
23 {open braces start code blocks and must be matched with a close brace
24 /**instantiating the Imagesprite and I have uploaded the file Dude2.png already
25 ** We tell the game that it is there and thats the one to use.
26 **Make sure to include the parenthises.
27 */
28 dude =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor ImageSprite("Dude2.png");
29
30 /**The image is located in the center of the screen*/
31 dude.setLocation(0.5, 0.5);
32 /**This sets the image size to half of the screen size*/
33 dude.setSize(0.5);
34 /**This adds the sprite to the screen*/
35 addSprite(dude);
36 }close braces end code blocks and must match an earlier open brace
37 }close braces end code blocks and must match an earlier open brace
|
Download/View examples/sprites/ImageSpriteExample.javanull