Project

General

Profile

« Previous | Next » 

Revision 4c864c68

Added by Leszek Koltunski almost 4 years ago

Further improve rotations of a Object layer - make them independent of physical screen size (now it depends on the angle of rotation and, if that's 0, on the speed (in inches of second) of the finger swipe done by the user.

View differences:

src/main/java/org/distorted/objects/RubikObject.java
620 620
    {
621 621
    final int NEAREST = 360/getBasicAngle();
622 622

  
623
    float angleAndSpeed = angle + 100*speed;
623
    int tmp = (int)((angle+NEAREST/2)/NEAREST);
624
    if( angle< -(NEAREST*0.5) ) tmp-=1;
624 625

  
625
    int tmp1 = (int)((angle+NEAREST/2)/NEAREST);
626
    if( angle< -(NEAREST*0.5) ) tmp1-=1;
626
    if( tmp!=0 ) return NEAREST*tmp;
627 627

  
628
    int tmp2 = (int)((angleAndSpeed+NEAREST/2)/NEAREST);
629
    if( angleAndSpeed< -(NEAREST*0.5) ) tmp2-=1;
630

  
631
    return NEAREST*(tmp1==0 ? tmp2 : tmp1);
628
    return speed> 1.5f ? NEAREST*(angle>0 ? 1:-1) : 0;
632 629
    }
633 630

  
634 631
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff