Objective c 移动节点和节点

Objective c 移动节点和节点,objective-c,sprite-kit,skspritenode,Objective C,Sprite Kit,Skspritenode,我的游戏中有以下设置: 名为_backgroundLayer的SKNode 一个重复的纹理,我把它添加到背景层上9次,使背景更大 名为levelButton的SKSprite,添加到_backgroundLayer[_BackgroundLayerAddChild:levelButton];。 我使用levelButton.ancorpoint=CGPointMake0.5,0.5;使LealBut纽在中间有一个锚点。 现在,当我设置levelButton.position=CGPointMak

我的游戏中有以下设置:

名为_backgroundLayer的SKNode 一个重复的纹理,我把它添加到背景层上9次,使背景更大 名为levelButton的SKSprite,添加到_backgroundLayer[_BackgroundLayerAddChild:levelButton];。 我使用levelButton.ancorpoint=CGPointMake0.5,0.5;使LealBut纽在中间有一个锚点。 现在,当我设置levelButton.position=CGPointMake0,0;和_backgroundLayer.position=CGPointMake0,0;levelButton的中间正确位于0,0,其中间位于屏幕左下角。那很好。 但是,如果我将levelButton移动为levelButton.position=CGPointMake100,0;和_backgroundLayer.position=CGPointMake-100,0;,正如我在下面所展示的,levelButton的中间应该仍然在屏幕的左下角0,0。然而,事实并非如此,levelButton更靠右,右边大约有50个像素。但不应该是这样,因为我正在将_backgroundlayer100移到左边-100,将_levelbutton100移到右边100。它应该留在原地

这些都是基本的东西,我不明白为什么它们不能正常工作。我可能做错了什么,但我找不到它,即使我已经阅读了iOS游戏的教程和一堆教程和技巧

请帮忙

现在,我的代码如下:

@implementation LevelSelectScene
{
   SKNode *_backgroundLayer;
}

-(id)initWithSize:(CGSize)size {

    /* Setup your scene here */
    _backgroundLayer = [SKNode node];
    _backgroundLayer.name = @"backgroundLayer";

    SKTexture *backgroundTexture = [SKTexture textureWithImageNamed:@"levelSelect"];

    int textureID = 0;

    for (int i = 0; i<3; i++) {
        for (int j = 0; j<3; j++) {

            SKSpriteNode *background = [SKSpriteNode spriteNodeWithTexture:backgroundTexture];

            background.anchorPoint = CGPointZero;
            background.position = CGPointMake((background.size.width)*i,
                                              (background.size.height)*j);
            background.zPosition = 0;
            background.name = [NSString stringWithFormat:@"background%d", textureID];

            textureID++;

            [_backgroundLayer addChild:background];
        }
    }

    [self addChild:_backgroundLayer];

    SKSpriteNode * levelButton = [SKSpriteNode spriteNodeWithImageNamed:@"lock"];
    levelButton.anchorPoint = CGPointMake(0.5, 0.5);
    levelButton.position = CGPointMake(100, 0);                 //IMPORTANT
    levelButton.zPosition = 150;
    levelButton.name = @"test";

    [_backgroundLayer addChild:levelButton];

    _backgroundLayer.position = CGPointMake(-100, 0);     //IMPORTANT
}
return self;
}
找到了! 我改变了背景层SKnode的比例,所以坐标不同