Exemplo n.º 1
0
  private void updateXYOnCollision() {
    Transition newInstance = new Transition();
    float dX = _currInstance._endX - _currInstance._startX;
    float dY = _currInstance._endY - _currInstance._startY;
    float intialY = _currInstance._startY;
    newInstance._startX = _currInstance._endX;
    newInstance._startY = _currInstance._endY;
    if (dX > 0 && dY > 0) {
      if (isInteger(intialY)) {
        newInstance._endX = _currInstance._endX - 0.5f;
        newInstance._endY = _currInstance._endY + 0.5f;
      } else {
        newInstance._endX = _currInstance._endX + 0.5f;
        newInstance._endY = _currInstance._endY - 0.5f;
      }
    } else if (dX < 0 && dY > 0) {
      if (isInteger(intialY)) {
        newInstance._endX = _currInstance._endX + 0.5f;
        newInstance._endY = _currInstance._endY + 0.5f;
      } else {
        newInstance._endX = _currInstance._endX - 0.5f;
        newInstance._endY = _currInstance._endY - 0.5f;
      }
    } else if (dX > 0 && dY < 0) {
      if (isInteger(intialY)) {
        newInstance._endX = _currInstance._endX - 0.5f;
        newInstance._endY = _currInstance._endY - 0.5f;
      } else {
        newInstance._endX = _currInstance._endX + 0.5f;
        newInstance._endY = _currInstance._endY + 0.5f;
      }

    } else {
      if (isInteger(intialY)) {
        newInstance._endX = _currInstance._endX + 0.5f;
        newInstance._endY = _currInstance._endY - 0.5f;
      } else {
        newInstance._endX = _currInstance._endX - 0.5f;
        newInstance._endY = _currInstance._endY + 0.5f;
      }
    }
    _currInstance = newInstance;
  }
Exemplo n.º 2
0
 private void updateXYWithoutCollision() {
   Transition newInstance = new Transition();
   float dX = _currInstance._endX - _currInstance._startX;
   float dY = _currInstance._endY - _currInstance._startY;
   newInstance._startX = _currInstance._endX;
   newInstance._startY = _currInstance._endY;
   if (dX > 0 && dY > 0) {
     newInstance._endX = _currInstance._endX + 0.5f;
     newInstance._endY = _currInstance._endY + 0.5f;
   } else if (dX > 0 && dY < 0) {
     newInstance._endX = _currInstance._endX + 0.5f;
     newInstance._endY = _currInstance._endY - 0.5f;
   } else if (dX < 0 && dY > 0) {
     newInstance._endX = _currInstance._endX - 0.5f;
     newInstance._endY = _currInstance._endY + 0.5f;
   } else if (dX < 0 && dY < 0) {
     newInstance._endX = _currInstance._endX - 0.5f;
     newInstance._endY = _currInstance._endY - 0.5f;
   }
   _currInstance = newInstance;
 }