我无法移动通过 SKPhysicsJoint 附加的精灵。我有一个如下所示的 touchesMoved 方法:
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
CGPoint positionInScene = [touch locationInNode:self];
CGPoint previousPosition = [touch previousLocationInNode:self];
CGPoint translation = CGPointMake(positionInScene.x - previousPosition.x, positionInScene.y - previousPosition.y);
CGPoint newPosition = CGPointMake(_selectedNode.position.x + translation.x, _selectedNode.position.y + translation.y);
[_selectedNode runAction:[SKAction moveTo:newPosition duration:0]];
}
它有点工作,但如果我将重力设置得非常低,它似乎只能将精灵移动 25%,如果我将重力设置为默认值,它几乎不会在 y 轴上移动。我很困惑,可能有很多东西,但我想也许我只需要设置速度或其他东西,但如果是这样,什么是合适的设置?