我正在尝试对SKSpodeNode中的阴影分组的SKSpriteNode执行某些操作。翻译工作正常,但轮换仍然是一个问题。
我实现了添加阴影,如下所示:
- (SKNode *) addShadow:(NSString *) nodeName At:(CGPoint) pos
{
float halfWdth = self.frame.size.width / 2.f;
float halfHght = self.frame.size.height / 2.f;
SKEffectNode *shadowEffect = [[SKEffectNode alloc] init];
shadowEffect.shouldEnableEffects = YES;
SKNode *shadowNode = [[SKNode alloc] init];
SKSpriteNode *shadow = [self copy];
shadow.color = [SKColor blackColor];
shadow.colorBlendFactor = 0.9;
shadow.blendMode = SKBlendModeAlpha;
[shadow setAlpha:0.7];
shadowEffect.filter = [self blurFilter];
shadow.position = CGPointMake(halfWdth + SHADOW_DELTA, halfHght);
shadow.zPosition = -10;
shadowEffect.name = @"shadow";
shadowEffect.blendMode = SKBlendModeAlpha;
[shadowEffect addChild:shadow];
self.zPosition = 3;
self.position = CGPointMake(halfWdth, halfHght + SHADOW_DELTA);
[shadowNode addChild:shadowEffect];
[shadowNode addChild:self];
shadowNode.name = nodeName;
shadowNode.position = pos;
shadowNode.zPosition = 3;
SKNode *container = [[SKNode alloc] init];
container.name = nodeName;
CGRect groupRect = [shadowNode calculateAccumulatedFrame];
halfWdth = groupRect.size.width / 2.f;
halfHght = groupRect.size.height / 2.f;
shadowNode.position = CGPointMake(-halfWdth, -halfHght);
[container addChild:shadowNode];
container.position = CGPointMake(pos.x + halfWdth, pos.y + halfHght);
return (container);
}
我找到了链接Rotate and scale the POSITION of several sprites based on a center point?。但是,我无法解决我的问题。
我使用以下代码段进行翻译和旋转;
翻译:
SKAction *moveAction = [SKAction moveBy:CGVectorMake(-2.f, mMoveY) duration:0.2f];
[paper runAction:moveAction completion:
^{
[self processHelp:@"help3];
}];
旋转:
SKAction *rotateAction = [SKAction rotateByAngle:0.75f * M_PI duration:0.4f];
[mainNode runAction:rotateAction];
如果有人可以指导我,我会很高兴。
此致
Neslisah。