2014-03-04 64 views
-2
#import "MainScene.h" 
static const CGFloat _scrollSpeed = 80.f; 
@implementation MainScene { 
    CCSprite *_hero; 
    CCPhysicsNode *_physicsNode; 
    CCNode *_ground1; 
    CCNode *_ground2; 
    NSArray *_grounds; 
} 
- (void)didLoadFromCCB { 
    _grounds = @[_ground1, _ground2]; 
} 
- (void)update:(CCTime)delta { 
    _hero.position = ccp(_hero.position.x + delta * _scrollSpeed, _hero.position.y); 
    _physicsNode.position = ccp(_physicsNode.position.x - (_scrollSpeed *delta), _physicsNode.position.y); 
    // loop the ground 
    for (CCNode *ground in _grounds) { 
     // get the world position of the ground 
     CGPoint groundWorldPosition = [_physicsNode convertToWorldSpace:ground.position]; 
     // get the screen position of the ground 
     CGPoint groundScreenPosition = [self convertToNodeSpace:groundWorldPosition]; 
     // if the left corner is one complete width off the screen, move it to the right 
     if (groundScreenPosition.x <= (-1 * ground.contentSize.width)) { 
      ground.position = ccp(ground.position.x + 2 * ground.contentSize.width, ground.position.y); 
     } 
    } 


} 
@end 

而在此行xcode的 「使用未聲明的標識符的」

if (groundScreenPosition.x <= (-1 * ground.contentSize.width)) { 

我有這樣的2個問題

  • 預期表達
  • 使用未聲明的標識符 'LT' 的

那是我的問題

貸款機構幫助我,我真的需要它之前可能

+0

用'<'替換'<'? – Polynomial

回答

0

無論你從你複製的代碼,它百分之轉義小於號,所以它放在&lt;,而不是<。所以只需用<替換&lt;即可。

+0

哦,非常感謝,它確定感謝你的人最好的 – user3380340