1
我想用没有运气,用触摸拖动,以精确的曲线方式移动精灵位置。到目前为止,我使用下面的代码,没有运气曲线雪碧运动COCOS2D
-(BOOL) ccTouchBegan:(UITouch*)touch withEvent:(UIEvent *)event
{
lastTouchLocation = [MultiLayer locationFromTouch:touch];
return YES;
}
-(void) ccTouchMoved:(UITouch*)touch withEvent:(UIEvent *)event
{
CGPoint currentTouchLocation = [MultiLayer locationFromTouch:touch];
moveTo = ccpSub(lastTouchLocation, currentTouchLocation);
lastTouchLocation = currentTouchLocation;
}
-(void) update:(ccTime)delta
{
CCSprite* sprite = [sprites objectAtIndex:1];
if (moveTo.x != 0){
float X = sprite.position.x + moveTo.x;
float Y = sprite.position.y + (pow(X,2));
sprite.position = CGPointMake(X, Y);
}
}
我试图模拟的曲线方式是在形式y = x^2。这是可行的吗? 在此先感谢!
同样问题与我。我的眼睛在回答。 – 2011-12-06 05:36:25