Guest User

Untitled

a guest
Nov 23rd, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. final int size = physics.boxes.size;
  2. for (int i = 0; i < size; ++i) {
  3. final Body box = physics.boxes.items[i];
  4. final int index = (Integer) box.getUserData();
  5.  
  6. batch.setColor(colors[index]);
  7. final Vector2 position = box.getPosition();
  8. final float angleRad = box.getAngle();
  9. final float cos = MathUtils.cos(angleRad);
  10. final float sin = MathUtils.sin(angleRad);
  11. final float angle = MathUtils.radiansToDegrees * angleRad;
  12. final ArrayList<Fixture> tmpFixList = box.getFixtureList();
  13. final int fixSize = tmpFixList.size();
  14.  
  15. for (int j = 0; j < fixSize; ++j) {
  16. final Vector2 tmpPos = (Vector2) tmpFixList.get(j)
  17. .getUserData();
  18. final float tmpX = tmpPos.x;
  19. final float tmpY = tmpPos.y;
  20. final float newX = tmpX * cos - tmpY * sin
  21. - Data.BLOCK_SIZE + position.x;
  22. final float newY = tmpX * sin + tmpY * cos
  23. - Data.BLOCK_SIZE + position.y;
  24. batch.draw(textureRegion, newX, newY, 1f, 1f, 2f, 2f, 1f,
  25. 1f, angle);
  26. }
  27. }
Add Comment
Please, Sign In to add comment