Ios 使用Cocos2D为iPhone绘制曲线

Ios 使用Cocos2D为iPhone绘制曲线,ios,cocoa-touch,cocos2d-iphone,bezier,curve,Ios,Cocoa Touch,Cocos2d Iphone,Bezier,Curve,我正在用Cocos2D做一个简单的游戏。用户可以触摸和跟踪小型移动对象的路径。然后,对象沿着路径移动。这类似于飞行控制游戏中的机械师 如何像那样移动对象。请帮助我解决此问题。任何示例代码或教程都会帮助我。谢谢。在您的touchesEnded/touchesMoved方法中,尝试执行以下操作: UITouch *touch = [touches anyObject]; if (touch) { CGPoint location = [touch locationInView:[touch

我正在用Cocos2D做一个简单的游戏。用户可以触摸和跟踪小型移动对象的路径。然后,对象沿着路径移动。这类似于飞行控制游戏中的机械师


如何像那样移动对象。请帮助我解决此问题。任何示例代码或教程都会帮助我。谢谢。

在您的touchesEnded/touchesMoved方法中,尝试执行以下操作:

UITouch *touch = [touches anyObject];

if (touch) {
    CGPoint location = [touch locationInView:[touch view]];
    CGPoint convertedPoint = [[CCDirector sharedDirector] convertToGL:location];
    id animation = [CCMoveTo actionWithDuration:0.1 position:convertedPoint];
    [playerShip runAction:animation];
   }