Sprites out of sync

Hello I experience a strange bug where my sprites are not sync with box2d internals anymore after a while (DebugDraw is).

Screens are available here:

http://dev.dschini.org/box2d/strange.html

Someone already had this problem before? Any help is welcome.
Are you somehow updating the sprite data separately from the Box2D "internals"? That's what it sounds like. Your internals are still correct, and DebugDraw is as well... so how are you rendering the sprites? Every time through the game loop you should get the location (and other data) from the Box2D shape(s)/body and render your sprite accordingly.

Bill
Well that's actually possible but i am not sure. My game loop looks quite complex.
I think I will check that again and then come back later with results.
Thanks for the tip!

Code:
if(bodyOnFocus){
  var currentXPos:Number = bodyOnFocus.GetPosition().x;
  var currentYPos:Number = bodyOnFocus.GetPosition().y;
  if(horizontalScrollAction == World.SCROLL_ACTION_LEFT && xCorrection <= 100){
    xCorrection+=5;
  }
  if(horizontalScrollAction == World.SCROLL_ACTION_RIGHT && xCorrection >= -100){
    xCorrection-=5;
  }
  if(verticalScrollAction == World.SCROLL_ACTION_UP && yCorrection <= 50){
    yCorrection+=2;
  }
  if(verticalScrollAction == World.SCROLL_ACTION_DOWN && yCorrection >= -50){
    yCorrection-=2;
  }
  centerX = Game.getInstance().stage.stageWidth/2 + xCorrection;
  centerY = Game.getInstance().stage.stageHeight/2 + 50; // + yCorrection;
  containerStageForeground.x =
    containerStage.x =
    containerStageBackground.x = - currentXPos*30 * containerStage.scaleX +   centerX;
  containerStageForeground.y =
    containerStage.y =
    containerStageBackground.y = - currentYPos*30 * containerStage.scaleY + centerY;
  containerPanorama.x = - currentXPos*20 * containerPanorama.scaleX + centerX;
  containerPanorama.y = - currentYPos*20 * containerPanorama.scaleY + centerY;
  containerBackground.x = - currentXPos*10 * containerBackground.scaleX + centerX;
  containerBackground.y = - currentYPos*10 * containerBackground.scaleY + centerY;
}
I still could not get it to work proper. I tried to isolate the problem.

Please see here:
http://dev.dschini.org/box2d/whatthe.html

Unfortunately you have to wait ca 90 seconds until it happens.
Don't know what I am doing wrong?
I think you've stumbled upon a Flash bug with rotation - it seems to me that the only one that comes "unstuck" is the one that's constantly rotating, i.e. its rotation value keeps increasing.

I looked into it, and found a link: http://www.pixelwit.com/blog/2008/01/fl ... ation-bug/ Apparently when rotation values pass 32767 (which, if you do the math, is about 91 rotations, and if you're rotating at 1 hz, there's your minute and a half...), the player screws them up.

So you'll want to complain to Adobe, and have them yell at whoever had the brilliant "optimization" idea to use 16 bit integers to store rotation values! While you're at it, have them smack the person that thought degrees were better than radians, too, because it's the combination of those two things that really makes this a noticeable problem! 🙂

Seriously, though, there's a workaround at that link I posted, you just have to make sure to use the modulo operator to pull your rotation values to a reasonable range before you apply them.
Hi ewjordan, thanks for your reply. That fixed my problem!

If you are interested, I updated the page and simplified the examples a little bit:

http://dev.dschini.org/box2d/whatthe.html

Thank you!
A more robust method would be to use a 2d vector or 2x2 matrix to store rotation. Those can never overflow.

Original thread: https://box2d.org/forum/viewtopic.php?t=1136