SpriteKit objective c 节点仅在 x 轴上移动

SpriteKit objective c node movement only on x axis

我正在使用 SriteKit 制作简单的游戏,球会上下弹跳,当球落下时,您需要将棋盘放在下方以便球弹回,现在我可以将棋盘放在屏幕上的任何位置,但我想要放入特定的 y 轴,所以板只能在 x 轴上移动。我的问题是:我做错了什么,我需要改变什么,所以它按我想要的方式工作? P.S对不起我的英语不好。

这是我的一小部分代码:

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    /* Called when a touch begins */
    for (UITouch *touch in touches) {
        CGPoint location = [touch locationInNode:self];
        SKSpriteNode *sprite = [SKSpriteNode spriteNodeWithImageNamed:@"board"];
        sprite.xScale = 0.5; 
        sprite.yScale = 0.5;
        sprite.position = location; 
        sprite.physicsBody = [SKPhysicsBody bodyWithRectangleOfSize:sprite.frame.size];  
        sprite.physicsBody.dynamic = NO;

        SKAction *delay = [SKAction waitForDuration:2];    
        SKAction *remove = [SKAction removeFromParent];      
        SKAction *actionSequence = [SKAction sequence:@[delay,remove]];      
        [sprite runAction:actionSequence];
        [self addChild:sprite];
    }
}

您需要通过 y 轴设置位置

CGPoint touchlocation = [touch locationInNode:self];
CGPoint location = CGPointMake(touchlocation.x,100);  //where 100 is the spot on the y axis you want to stay on