public override void DidAccelerate(CCAcceleration pAccelerationValue)
        {
            CCDirector pDir = CCDirector.SharedDirector;
            CCSize winSize = pDir.WinSize;

            /*FIXME: Testing on the Nexus S sometimes m_pBall is NULL */
            if (m_pBall == null)
            {
                return;
            }

            CCSize ballSize = m_pBall.ContentSize;

            CCPoint ptNow = m_pBall.Position;
            CCPoint ptTemp = pDir.ConvertToUi(ptNow);

            //CCLog.Log("Accelerate : X: {0} Y: {1} Z: {2}", pAccelerationValue.X, pAccelerationValue.Y, pAccelerationValue.Z);
#if ANDROID
            ptTemp.X -= (float) pAccelerationValue.X * 9.81f;
            ptTemp.Y += (float) pAccelerationValue.Y * 9.81f;
#else
            //ptTemp.X -= (float) pAccelerationValue.Y * 9.81f;
            //ptTemp.Y -= (float) pAccelerationValue.X * 9.81f;
            ptTemp.X += (float)pAccelerationValue.X * 9.81f;
            ptTemp.Y += (float)pAccelerationValue.Y * 9.81f;
#endif

            CCPoint ptNext = pDir.ConvertToGl(ptTemp);
            ptNext.X = MathHelper.Clamp(ptNext.X, (ballSize.Width / 2.0f), (winSize.Width - ballSize.Width / 2.0f));
            ptNext.Y = MathHelper.Clamp(ptNext.Y, (ballSize.Height / 2.0f), (winSize.Height - ballSize.Height / 2.0f));
            m_pBall.Position = ptNext;
        }
Beispiel #2
0
 public virtual void DidAccelerate(CCAcceleration pAccelerationValue)
 {
 }
Beispiel #3
0
 public virtual void DidAccelerate(CCAcceleration pAccelerationValue)
 {
 }
        public override void DidAccelerate(CCAcceleration pAccelerationValue)
        {
            base.DidAccelerate(pAccelerationValue);

            //hero.move(pAccelerationValue.X);
        }
Beispiel #5
0
 public virtual void didAccelerate(CCAcceleration pAccelerationValue)
 {
     CCLog.Log("Layer2 accel");
 }
Beispiel #6
0
		void HandleAccelerate (CCAcceleration acceleration)
		{
			if(gameSuspended) 
				return;
			float accel_filter = 0.1f;
			bird_vel.X = bird_vel.X * accel_filter + (float)acceleration.X * (1.0f - accel_filter) * 500.0f;
		}