Advertisement
Guest User

Jon_two

a guest
Mar 1st, 2012
314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //On Tick happens every frame
  2.         private function onTick(e:Event):void {
  3.             bytes.position = 0;
  4.             stepTime = getTimer();
  5.             __box2DANE.step();
  6.             stepTime = getTimer() - stepTime;
  7.             bytes.position = 0;
  8.            
  9.             //This is usually either 0 or 1 ms
  10.             //trace("Step Time: " + stepTime);
  11.            
  12.             var box:BoxActor;
  13.             var id:Number;
  14.            
  15.             //Forever loop the bytearray...
  16.             while(true) {
  17.                 //Read the first double which is the ID of the box
  18.                 id = bytes.readDouble();
  19.                 if (id == -1.0) {
  20.                     //If the id is -1.0 its a terminator and we don't need to parse anymore.
  21.                     //This helps if all the bodies are asleep
  22.                     break;
  23.                 }
  24.                 else {
  25.                     //Get the box from the dictionary
  26.                     box = bodies[id] as BoxActor;
  27.                     //assign the values
  28.                     box.x = bytes.readDouble();
  29.                     box.y = bytes.readDouble();
  30.                     box.rotation = bytes.readDouble(); 
  31.                 }
  32.             }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement