Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //On Tick happens every frame
- private function onTick(e:Event):void {
- bytes.position = 0;
- stepTime = getTimer();
- __box2DANE.step();
- stepTime = getTimer() - stepTime;
- bytes.position = 0;
- //This is usually either 0 or 1 ms
- //trace("Step Time: " + stepTime);
- var box:BoxActor;
- var id:Number;
- //Forever loop the bytearray...
- while(true) {
- //Read the first double which is the ID of the box
- id = bytes.readDouble();
- if (id == -1.0) {
- //If the id is -1.0 its a terminator and we don't need to parse anymore.
- //This helps if all the bodies are asleep
- break;
- }
- else {
- //Get the box from the dictionary
- box = bodies[id] as BoxActor;
- //assign the values
- box.x = bytes.readDouble();
- box.y = bytes.readDouble();
- box.rotation = bytes.readDouble();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement