examples/sprites/CustomStringSprite

From FANG

Jump to: navigation, search

01 package examples.sprites;
02 //start auto-imports
03 //end auto-imports
04 
05 import fang2.core.*;
06 import fang2.sprites.*;
07 import fang2.transformers.*;
08 import fang2.attributes.*;
09 import java.awt.*;
10 import java.awt.geom.*;
11 
12 /**
13  * This shows a bunch of tanks on a screen.
14  @author Alan Davis
15  */
16 
17 public class CustomStringSprite extends Game
18 {
19   /**
20   
21   **/
22   StringSprite tank;
23   
24   /**sets up the game*/
25   public void setup()
26   {
27     /**This is the StringSprite initiation.
28     ***I put several letters in to show that it is possible
29     *** because we are playing with fonts. Think Wingdings.
30     **/
31     tank = new StringSprite"A B C D\n" +
32                              "E F G H\n" +
33                              "I J K L\n" +
34                              "M N O P" );
35                              
36     /**Sets the font to be no more than 80% of the screen size.
37     **/
38     tank.setSize0.8 );
39     
40     /**Puts the Sprite in the middle of the screen*/
41     tank.setLocation0.50.5 );
42     
43     /**This is what you need to change your regular font to a new one.
44     ***It finds your file in the resource folder with the name you gave the font.
45     **/
46     tank.setFontFamilyName"Tank" );
47     
48     /**Dont forget to add your sprite to the game.
49     **/
50     addSpritetank );
51   }
52   
53   /**handle input and game events*/
54   public void advance()
55   {}
56 }


Download/View examples/sprites/CustomStringSprite.java//start auto-imports //end auto-imports

import fang2.core.*; import fang2.sprites.*; import fang2.transformers.*; import fang2.attributes.*; import java.awt.*; import java.awt.geom.*;

/**

* This shows a bunch of tanks on a screen.
* @author Alan Davis
*/

public class CustomStringSprite extends Game { /**

**/ StringSprite tank;

/**sets up the game*/ public void setup() { /**This is the StringSprite initiation. ***I put several letters in to show that it is possible *** because we are playing with fonts. Think Wingdings. **/ tank = new StringSprite( "A B C D\n" + "E F G H\n" + "I J K L\n" + "M N O P" );

/**Sets the font to be no more than 80% of the screen size. **/ tank.setSize( 0.8 );

/**Puts the Sprite in the middle of the screen*/ tank.setLocation( 0.5, 0.5 );

/**This is what you need to change your regular font to a new one. ***It finds your file in the resource folder with the name you gave the font. **/ tank.setFontFamilyName( "Tank" );

/**Dont forget to add your sprite to the game. **/ addSprite( tank ); }

/**handle input and game events*/ public void advance() {} }





Views
Personal tools
Add to 
del.icio.usAdd to 
diggAdd to 
FacebookAdd to 
favoritesAdd to 
GoogleAdd to 
MySpaceAdd to 
PrintAdd to 
SlashdotAdd to 
StumbleUponAdd to 
Twitter

Games
Games