Ejemplo n.º 1
0
        public void UpdateWordRotation()
        {
            if (orientationButton != null)
            {
                rotationWholeWord = orientationButton.currentRotation;
            }

            if (rotationWholeWord != 0.0f)
            {
                //Globals.g_main.SetGLMatrixMode(GL_MODELVIEW);
                //glLoadIdentity();
                //glScalef(Constants.kScaleForShorts, Constants.kScaleForShorts, 0.0f);
                //glPushMatrix();
                float roatation = rotationWholeWord;
                float yThing    = Globals.g_world.screenHeight;
                float x         = position.x;
                float y         = position.y;
                if (Globals.deviceIPad)
                {
                    x *= 2.0f;
                    x += 64.0f;
                    y *= 2.0f;
                }

                CGPoint tempWordPos     = Utilities.CGPointMake(x, y);
                CGPoint vectorToBasePos = Utilities.CGPointMake(tempWordPos.x, yThing - tempWordPos.y);
                float   baseAngle       = Constants.PI_ - Utilities.GetAngleFromXYP1(vectorToBasePos.x, vectorToBasePos.y);
                CGPoint positionWas     = tempWordPos;
                float   distance        = Utilities.GetDistanceP1(Utilities.CGPointMake(0, yThing), positionWas);
                CGPoint newPosVec       = Utilities.GetVectorFromAngle(baseAngle + roatation);
                newPosVec.x *= distance;
                newPosVec.y *= distance;
                CGPoint positionNow = newPosVec;
                positionNow.y = -positionNow.y;
                CGPoint diff;
                diff.x = positionNow.x - positionWas.x;
                diff.y = positionNow.y - (yThing - positionWas.y);
                //glRotatef((roatation) * (360.0 / (Constants.TWO_PI)), 0, 0, 1);
                //glTranslatef(diff.x * Constants.kScreenMultiplierForShorts, diff.y * Constants.kScreenMultiplierForShorts, 0.0f);
                CGPoint orientationButtonPos = Utilities.CGPointMake((orientationButton.myButton).position.x, (orientationButton.myButton).position.y);
                if (Globals.deviceIPad)
                {
                    orientationButtonPos.x *= 2.0f;
                    orientationButtonPos.x += 64.0f;
                    orientationButtonPos.y *= 2.0f;
                }

                CGPoint startOffset  = Utilities.CGPointMake(tempWordPos.x - orientationButtonPos.x, tempWordPos.y - orientationButtonPos.y);
                float   startAngle   = Utilities.GetAngleFromXYNewP1(startOffset.x, startOffset.y);
                float   offsetLength = Utilities.GetDistanceP1(Utilities.CGPointMake(0, 0), startOffset);
                CGPoint normalAngle  = Utilities.GetVectorFromAngleNew(startAngle - roatation);
                normalAngle.x *= offsetLength;
                normalAngle.y *= offsetLength;
                CGPoint offset;
                offset.x = startOffset.x - normalAngle.x;
                offset.y = startOffset.y - normalAngle.y;
                //glTranslatef(-offset.x * 20.0f, offset.y * 20.0f, 0.0f);
            }
        }