Comment faire pour faire pivoter l'image-objet autour de son centre dans cocos2d dans ccTouchesMoved. J'ai trouvé du code, mais ce n'est pas ce dont j'ai besoin. J'ai besoin de faire pivoter le sprite comme une photo dans l'application Galerie de photos.Comment faire pour faire pivoter et redimensionner une image-objet comme une image dans la bibliothèque lybrary
- (void)ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
NSArray *allTouch = [touches allObjects];
if([allTouch count] > 1){
UITouch *touch = [allTouch objectAtIndex:0];
CGPoint point = [touch locationInView: [touch view]];
point = [[CCDirector sharedDirector] convertToGL:point];
float angleRadians = atanf((float)point.y/(float)point.x);
float angleDegrees = CC_RADIANS_TO_DEGREES(angleRadians);
float cocosAngle = -1 * angleDegrees;
imageFromPicker.rotation = imageFromPicker.rotation + cocosAngle;
}
}
si vous souhaitez faire pivoter plus facilement, vous pouvez ajouter un coeficient flotter ici rotation \t = atan2 (PY, Px) * coef; – JonLOo
Cela fonctionne :) J'ai ajouté un coefficient et son aspect est très bon. J'ai également ajouté la méthode d'écaillage et il reste à ajouter le masque, puis enregistrer l'image-objet. Je vous remercie! – BUDDAx2
vous êtes les bienvenus :) – JonLOo