scg/ch03/Strings

From FANG

Jump to: navigation, search

01 package scg.ch03;
02 
03 import fang2.core.Game;
04 import fang2.sprites.StringSprite;
05 
06 /** Demonstration of StringSprite. Msg centered horizontally. */
07 public class Strings
08   extends Game {
09   /** Write the poem in four strings (6 lines).*/
10   @Override
11   public void setup() {
12     // '\n' sequence is the new line character (starts a new line)
13     StringSprite meddle = new StringSprite(
14         "Do not meddle in\nthe affairs of");
15     meddle.setLineHeight(0.10);
16     meddle.setColor(getColor("white"));
17     meddle.setLocation(0.50.15);
18     addSprite(meddle);
19 
20     StringSprite dragons = new StringSprite("DRAGONS");
21     dragons.setLineHeight(0.15);
22     dragons.setColor(getColor("green"));
23     dragons.setLocation(0.50.4);
24     addSprite(dragons);
25 
26     StringSprite thou = new StringSprite(
27         "for thou art crunchy\nand go well with");
28     thou.setLineHeight(0.10);
29     thou.setColor(getColor("white"));
30     thou.setLocation(0.50.65);
31     addSprite(thou);
32 
33     StringSprite ketchup = new StringSprite("ketchup");
34     ketchup.setLineHeight(0.20);
35     ketchup.setColor(getColor("SCG Red"));// red in the book
36     ketchup.setLocation(0.50.85);
37     addSprite(ketchup);
38   }
39 }
40 
41 //Uploaded on Mon Mar 29 21:40:00 EDT 2010


Download/View scg/ch03/Strings.java





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