我有一个 CGMuatbleCGPathRef,我正在尝试创建一个路径参考来移动我的外星人。我现在保持简单,但以后会很复杂。
我有下面的代码将 SpriteNode 移动到一点,但他从不移动。有人可以指出我做错了什么吗?我有一个动画动作在他身上运行,也有重复动作。
首先调用的方法来启动动画纹理帧(作品)
-(void)walkingBear
{
//This is our general runAction method to make our bear walk.
[spaceMosquito runAction:[SKAction repeatActionForever:
[SKAction animateWithTextures:moqFrames
timePerFrame:0.4f
resize:NO
restore:YES]] withKey:@"walkingInPlaceBear"];
return;
}
移动外星人的行动
-(void) normalStance {
CGMutablePathRef cgpath = CGPathCreateMutable();
CGPoint endPos = CGPointMake(300, 600);
CGPoint startPos = CGPointMake(700, 900);
CGPathMoveToPoint(cgpath, nil, startPos.x, startPos.y);
CGPathMoveToPoint(cgpath, nil, endPos.x, endPos.y);
[spaceMosquito runAction:[SKAction followPath:cgpath duration:5.0f ] withKey:@"moveme"];
CGPathRelease(cgpath);
}