J'essaie sans aucune chance de déplacer une position d'image-objet d'une manière simétrique avec le glisser-toucher. Jusqu'à présent, j'utilise le code suivant avec pas de chanceCurve Sprite Movement 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);
}
}
La façon dont la courbe je suis en train de simuler est sous la forme y = x^2. Est-ce que c'est posible? Merci d'avance!
même Problème avec moi. mes yeux sur la réponse. –