Project

General

Profile

« Previous | Next » 

Revision a034956d

Added by Leszek Koltunski over 3 years ago

RubikControl: rotate the cube 2.

View differences:

src/main/java/org/distorted/control/RubikControlWhole.java
501 501
    mDynMoveShad1.add(mPosition1);
502 502
    mDynMoveHand2.add(mPosition2);
503 503
    mDynMoveShad2.add(mPosition2);
504

  
505
    float x1 = point1s.get0() + mWidth*0.5f;
506
    float y1 = mHeight*0.5f - point1s.get1();
507
    float x2 = point2s.get0() + mWidth*0.5f;
508
    float y2 = mHeight*0.5f - point2s.get1();
509

  
510
    RubikSurfaceView view = mControl.getSurfaceView();
511
    view.prepareDown();
512
    view.prepareDown2();
513
    view.actionDown(x1,y1);
514
    view.actionDown2(x1,y1,x2,y2);
504 515
    }
505 516

  
506 517
///////////////////////////////////////////////////////////////////////////////////////////////////
......
786 797
    s001 = mWidth*0.0001f;
787 798
    s014 = mWidth*0.14f;
788 799
    s033 = mWidth*0.33f;
789
    F    = 0.60f;
800
    F    = 0.70f;
790 801
    }
791 802

  
792 803
///////////////////////////////////////////////////////////////////////////////////////////////////
......
898 909
              if( mCurrentStage==3 )
899 910
                {
900 911
                RubikSurfaceView view = mControl.getSurfaceView();
901
                float x = tmpBuffer[0]+mWidth*0.5f;
902
                float y = mHeight*0.5f-tmpBuffer[1];
903
                view.actionMove(x,y);
912
                float x1 = tmpBuffer[0]+mWidth*0.5f;
913
                float y1 = mHeight*0.5f-tmpBuffer[1];
914
                view.actionMove(x1,y1,0,0);
904 915
                }
905 916

  
906 917
              if( finished1 )
......
919 930
              boolean finished2_2 = mDyn2.get( tmpBuffer,3, time, mDiffTime);
920 931
              mPosition1.set(tmpBuffer[0], tmpBuffer[1], tmpBuffer[2]);
921 932
              mPosition2.set(tmpBuffer[3], tmpBuffer[4], tmpBuffer[5]);
922
              if( finished2_1 && finished2_2 ) stageFinished(mCurrentStage);
933

  
934
              if( mCurrentStage==9 || mCurrentStage==10 || mCurrentStage==11 )
935
                {
936
                RubikSurfaceView view = mControl.getSurfaceView();
937
                float x1 = tmpBuffer[0]+mWidth*0.5f;
938
                float y1 = mHeight*0.5f-tmpBuffer[1];
939
                float x2 = tmpBuffer[3]+mWidth*0.5f;
940
                float y2 = mHeight*0.5f-tmpBuffer[4];
941
                view.prepareMove(x1,y1,x2,y2);
942
                view.actionMove(x1,y1,x2,y2);
943
                }
944

  
945
              if( finished2_1 && finished2_2 )
946
                {
947
                 if( mCurrentStage==11 )
948
                  {
949
                  RubikSurfaceView view = mControl.getSurfaceView();
950
                  view.prepareUp();
951
                  view.actionUp2(true,0,0,false,0,0);
952
                  view.actionUp();
953
                  }
954

  
955
                stageFinished(mCurrentStage);
956
                }
923 957
              break;
924 958
      case 4: boolean finished4_1 = mDyn1.get( tmpBuffer,0, time, mDiffTime);
925 959
              boolean finished4_2 = mDyn2.get( tmpBuffer,3, time, mDiffTime);
src/main/java/org/distorted/main/RubikSurfaceView.java
633 633
      mPointer2 = INVALID_POINTER_ID;
634 634
      }
635 635

  
636
///////////////////////////////////////////////////////////////////////////////////////////////////
637

  
638
    public void prepareDown2()
639
      {
640
      mPointer2 = 0;
641
      }
642

  
643
///////////////////////////////////////////////////////////////////////////////////////////////////
644

  
645
    public void prepareMove(float x1, float y1, float x2, float y2)
646
      {
647
      mX1 = x1;
648
      mY1 = y1;
649
      mX2 = x2;
650
      mY2 = y2;
651
      }
652

  
636 653
///////////////////////////////////////////////////////////////////////////////////////////////////
637 654

  
638 655
    public void prepareUp()
......
644 661

  
645 662
///////////////////////////////////////////////////////////////////////////////////////////////////
646 663

  
647
    public void actionMove(float pX, float pY)
664
    public void actionMove(float x1, float y1, float x2, float y2)
648 665
      {
649
      //android.util.Log.e("D", "ACTION MOVE x="+pX+" y="+pY+" mDragging="+mDragging);
666
      float pX = mPointer1 != INVALID_POINTER_ID ? x1 : x2;
667
      float pY = mPointer1 != INVALID_POINTER_ID ? y1 : y2;
650 668

  
651 669
      float x = (pX - mScreenWidth*0.5f)/mScreenMin;
652 670
      float y = (mScreenHeight*0.5f -pY)/mScreenMin;
......
676 694

  
677 695
    public void actionDown(float x, float y)
678 696
      {
679
      //android.util.Log.e("D", "ACTION DOWN x="+x+" y="+y);
680

  
681 697
      mX = (x -  mScreenWidth*0.5f)/mScreenMin;
682 698
      mY = (mScreenHeight*0.5f - y)/mScreenMin;
683 699

  
......
688 704

  
689 705
    public void actionUp()
690 706
      {
691
      //android.util.Log.e("D", "ACTION UP");
692

  
693 707
      if( mContinuingRotation )
694 708
        {
695 709
        finishRotation();
......
753 767
                                               actionDown(mX1, mY1);
754 768
                                               break;
755 769
         case MotionEvent.ACTION_MOVE        : prepareMove(event);
756
                                               float x = mPointer1 != INVALID_POINTER_ID ? mX1 : mX2;
757
                                               float y = mPointer1 != INVALID_POINTER_ID ? mY1 : mY2;
758
                                               actionMove(x,y);
770
                                               actionMove(mX1, mY1, mX2, mY2);
759 771
                                               break;
760 772
         case MotionEvent.ACTION_UP          : prepareUp(event);
761 773
                                               actionUp();

Also available in: Unified diff