2013-02-03 64 views
0

我不明白爲什麼這不起作用。我正在編寫一個遊戲,涉及在屏幕上滾動塊/列的塊。我將自己的方向嚴格限制爲肖像,但並不表現如此。不正確的iPhone方向?

當我調用下面的方法時,它會從鍋中傳遞速度。使用日誌時,我能夠看到將設備顛倒和平移,就好像我的方向支持肖像一樣。我怎樣才能完全關閉除肖像以外的任何東西?

下面是一些代碼來幫助解釋我想要做什麼,並希望證明我的理智。

bool horizontalPan = (fabs(velocity.x) >= (fabs(velocity.y))); 
    if (horizontalPan) 
    { 
     if (fabs(velocity.x) > MAX_VELOCITY) 
     { 
      if (velocity.x > 0) 
       velocity = CGPointMake(MAX_VELOCITY, 0); 
      else 
       velocity = CGPointMake(-MAX_VELOCITY, 0); 
     } 
     else 
     { 
      velocity = CGPointMake(velocity.x, 0); 
     } 
     velocity = ccpMult(velocity, PAN_SENSITIVITY); 
     [self panRow:velocity object:object]; 
    } 
    else 
    { 
     if (fabs(velocity.y) > MAX_VELOCITY) 
     { 
      if (velocity.y > 0) 
       velocity = CGPointMake(0, MAX_VELOCITY); 
      else 
       velocity = CGPointMake(0, -MAX_VELOCITY); 
     } 
     else 
     { 
      velocity = CGPointMake(0, velocity.y); 
     } 
     velocity = ccpMult(velocity, PAN_SENSITIVITY); 
     [self panColumn:velocity object:object]; 
    } 
} 

回答

0

你是如何 '嚴格限制對畫像' 你用

-(BOOL)shouldAutorotate{ 
    return NO; 
} 
+0

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { \t回UIInterfaceOrientationIsPortrait(interfaceOrientation); } – Clev3r

+0

shouldAutorotate方法必須去哪裏? – Clev3r