0

このコードを使用して無限ループを実装していますが、オフスクリーンの画像座標が変更されるたびに 1 ~ 2 秒のギャップがあります。なぜ彼らは現れるのですか?修正方法は?SpriteBuilder も使用しています。

#import "MainScene.h"
static const CGFloat scrollSpeed =100.f;
@implementation MainScene{
 CCPhysicsNode *_world; 
    CCNode *_oneb;
    CCNode *_twob;
       NSArray *_bb;


}
- (void)didLoadFromCCB {
    _bb = @[_oneb, _twob];
}

-(void)update:(CCTime)delta{
  _world.position=ccp(_world.position.x - (scrollSpeed * delta), _world.position.y  ); // moving world
    for (CCNode *ground in _bb) {
        // get the world position of the ground
        CGPoint groundWorldPosition = [_world 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

編集: -1 を -0.5 に変更しました。正常に動作します!

ここに画像の説明を入力

ここに画像の説明を入力

4

1 に答える 1