标签:
for (int i = 0; i < 1; i++) { //< [arr count]; i++) {
CIFaceFeature *feature = [arr objectAtIndex:i];
double xPosition = (feature.leftEyePosition.x + feature.rightEyePosition.x+feature.mouthPosition.x)/(3*image.size.width) ;
double yPosition = (feature.leftEyePosition.y + feature.rightEyePosition.y+feature.mouthPosition.y)/(3*image.size.height);
double dist = sqrt(pow((feature.leftEyePosition.x - feature.rightEyePosition.x),2)+pow((feature.leftEyePosition.y - feature.rightEyePosition.y),2))/image.size.width;
yPosition += dist;
CGSize size = [[CCDirector sharedDirector] winSize];
pumpkin.opacity = 255;
pumpkin.scale = 5*(size.width*dist)/256.0;
//int randomPumpkin = ((arc4random() % 10) + 5);
[pumpkin setDisplayFrame:[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:[NSStringstringWithFormat:@"pumpkin%d.png", pumpkin_count + 4]]];
CCMoveTo *moveAction = [CCMoveTo actionWithDuration:0 position:ccp((size.width * (xPosition)), (size.height * ((yPosition))))];
[pumpkin runAction:moveAction];
}
标签:
原文地址:http://www.cnblogs.com/isItOk/p/4872515.html