0
-(void)moveCamera:(CGpoint)resultVector {
float centerX, centerY, centerZ;
float eyeX, eyeY, eyeZ;

[self.camera centerX:&centerX centerY=&centerY centerZ=&centerZ];
[self.camera eyeX:&eyeX eyeY:&eyeY eyeZ:&eyeZ];

float newX = (resultVector.x - actorOriginalPosition.x) + (actorOriginalPosition.x - screenSize.width/2);
float newY = (resultVector.y - actorOriginalPosition.y) + (actorOriginalPosition.y - screenSize.height/2);

[self.camera setCenterX:newX centerY=newY centerZ:-150.0f];
[self.camera setEyeX:newX eyeY=newY eyeZ:eyeZ];

}

ここで resultVector はアクター currentPosition です

4

1 に答える 1

0

更新機能で:

CGPoint direction = [self getPoint:myBody->GetPosition()];
[self setPosition:direction];


- (CGPoint)getPoint:(b2Vec2)vec
{
    CGSize screen = [[CCDirector sharedDirector] winSize];

    float x = vec.x * PTM_RATIO;
    float y = vec.y * PTM_RATIO;

    x = MAX(x, screen.width/2);
    y = MAX(y, screen.height/2);

    float _x = area.width  -  (screen.width/2);
    float _y = area.height - (screen.height/2);

    x = MIN(x, _x);
    y = MIN(y, _y);

    CGPoint goodPoint = ccp(x,y);

    CGPoint centerOfScreen = ccp(screen.width/2, screen.height/2);
    CGPoint difference = ccpSub(centerOfScreen, goodPoint);

    return difference;
}
于 2013-04-06T13:22:34.907 に答える