ClickContextExample

From ggc

Jump to: navigation, search

01 import fang.*;
02 import java.awt.*;
03 import java.awt.geom.*;
04 
05 /**
06  * All about my game here.
07  @author Jam Jenkins
08  */
09 public class ClickContextExample extends GameLoop
10 {
11   private int clickCount;
12 
13   /**sets up the game*/
14   public void startGame()
15   {
16     clickCount=0;
17   }
18 
19   private void doStage1Interaction()
20   {
21     PolygonSprite poly=new PolygonSprite(3);
22     Point2D.Double location=getPlayer().getMouse().getClickLocation();
23     poly.setLocation(location);
24     poly.setScale(0.2);
25     canvas.addSprite(poly);
26     clickCount=1;
27   }
28 
29   private void doStage2Interaction()
30   {
31     PolygonSprite poly=new PolygonSprite(4);
32     Point2D.Double location=getPlayer().getMouse().getClickLocation();
33     poly.setLocation(location);
34     poly.setScale(0.2);
35     canvas.addSprite(poly);
36     clickCount=0;
37   }
38 
39   /**handle input and game events*/
40   public void advanceFrame(double timePassed)
41   {
42     if(getPlayer().getMouse().getClickLocation()!=null)
43     {
44       if(clickCount==0)
45       {
46         doStage1Interaction();
47       }
48       else if(clickCount==1)
49       {
50         doStage2Interaction();
51       }
52     }
53   }
54 }


Download/View ClickContextExample.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