SKAction前进
我如何获得SKNode
前进?
我已经能够使用[SKAction moveByX:y:duration:]
使节点在一个固定的方向上移动,但是我希望它在相对于它所面对的方向的方向上移动。
我正在寻找使每个节点转45度,然后“走”向前50个像素。
这似乎很简单,我只是无法find它。
这将旋转,然后朝你的水龙头
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { for (UITouch *touch in touches) { for (UITouch *touch in touches) { CGPoint location = [touch locationInNode:self]; CGPoint diff = CGPointMake(location.x - _myPlayer.position.x, location.y - _myPlayer.position.y); CGFloat angleRadians = atan2f(diff.y, diff.x); [_myPlayer runAction:[SKAction sequence:@[ [SKAction rotateToAngle:angleRadians duration:1.0], [SKAction moveByX:diff.xy:diff.y duration:3.0] ]]]; } } }
我也考虑过这个。 我想在继续之前创build一个似乎正在转向的节点。 我已经考虑过这样做的一种方法是让子节点附加在场景中移动的节点的“最前面”部分。 然后我会计算点击forms的子节点的距离。 那有意义吗? 从本质上讲,我将能够从场景中的任意位置轻敲节点的前端。