Gerard-Meier

Untitled

Mar 11th, 2012
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.31 KB | None | 0 0
  1. class enemy {
  2.     constructor() {
  3.         foostate = new stateFoo(this);
  4.         barstate = new stateBar(this);
  5.         // more states.
  6.  
  7.  
  8.         // assign a default state:
  9.         currentstate = foostate;
  10.     }
  11.  
  12.     // called each frame.
  13.     update() {
  14.         currentstate->run();
  15.     }
  16.    
  17.     setState(newstate) {
  18.         currentstate = newstate;
  19.     }
  20.  
  21.  
  22. };
Advertisement
Add Comment
Please, Sign In to add comment