0

画面上に 9 つのブロックがあり (BlockView は、物事を追跡するためのいくつかのプロパティを持つビューのサブクラスにすぎません)、各ブロックの上部に煙のパーティクル エミッターを追加して、各ブロックの上部から煙が立ち上るのを追加したいと考えています。 . ブロックとパーティクル エミッターを保持するビューを作成し、ブロックをサブビューの前面に移動して、ブロックが前面にくるようにします。ただし、これにより、デバイス (iphone 6) が非常に遅くなり、パン ジェスチャでブロックを移動することが非常に困難になります。

SmokeParticles.sks: 発生率 3 (最大 0 に設定)、寿命 10 (範囲 100)、コードで設定された位置範囲。

各ビューにパーティクル エミッタを追加するための私のコードは次のとおりです (パーティクル エミッタはあまり得意ではないので、アドバイスをいただければ幸いです! :D)

    - (void)addEffectForSingleBlock:(BlockView *)view
{
    CGFloat spaceBetweenBlocksHeight = (self.SPACE_TO_WALLS * self.view.frame.size.height + self.SPACE_BETWEEN_BLOCKS*self.view.frame.size.width + self.WIDTH_OF_BLOCK*self.view.frame.size.height) - (self.HEIGHT_OF_BLOCK*self.view.frame.size.height + self.SPACE_TO_WALLS * self.view.frame.size.height);
    view.alpha = 1.0;
    CGRect frame2 = [view convertRect:view.bounds toView:self.view];
    UIView * viewLarge = [[UIView alloc] initWithFrame:frame2];
    [self.view addSubview:viewLarge];
    CGRect frame1 = [view convertRect:view.bounds toView:viewLarge];
    view.frame = frame1;
    [viewLarge addSubview:view];
    SKEmitterNode *burstNode = [self particleEmitterWithName:@"SmokeParticles"];
    CGRect frame = CGRectMake(view.bounds.origin.x-self.SPACE_BETWEEN_BLOCKS*self.view.frame.size.width, view.bounds.origin.y-self.SPACE_BETWEEN_BLOCKS_HEIGHT, view.bounds.size.width+self.SPACE_BETWEEN_BLOCKS*self.view.frame.size.width, view.bounds.size.height/2);
    SKView *skView = [[SKView alloc] initWithFrame:frame];
    [viewLarge addSubview:skView];
    SKScene *skScene = [SKScene sceneWithSize:skView.frame.size];
    [skScene addChild:burstNode];
    [viewLarge bringSubviewToFront:view];
    [burstNode     setParticlePositionRange:CGVectorMake(skView.frame.size.width/5, skView.frame.size.height/100.0)];
    skView.allowsTransparency = YES;
    skScene.backgroundColor = [UIColor clearColor];
    skView.backgroundColor = [UIColor clearColor];
    [skView presentScene:skScene];
    [burstNode setPosition:CGPointMake(skView.frame.size.width/2, -skView.frame.size.height*0.25)];
}
4

1 に答える 1