2015-08-13 73 views
2

有點古怪這裏,我有一個粒子發射器添加到SKShapeNode (顆粒應該跟隨線)myParticleEmitter古怪(0.0創建僞影)而從A點繪製到B點

然而當它它也有一個有點粒子系統,坐在0,0 伊夫的移動起來一點,所以你可以看到它更好

任何想法如何這可能發生?, 我會發佈下面的代碼,但我仍然無法找到任何東西,我測試過其他紋理設置setStrokeTexture - incase線正在做一些鬼鬼祟祟的額外部分 - 但沒有它看起來很好....並創建在LinkWithNumberClass精靈之間的線......

// SKSpriteNode SKPhysicsContactDelegate

if (isUsingParticles == YES) { 

    //create new line 
    SKShapeNode*lineNode02 = [SKShapeNode node]; 
    lineNode02.lineWidth = 10; 
    lineNode02.name = @"lineNode"; 

    //clear line of colour 
    lineNode02.fillColor = [SKColor clearColor]; 
    lineNode02.strokeColor = [SKColor clearColor]; 

    //create the path the line follows (line joins two sprites) 
    CGMutablePathRef pathToDraw = CGPathCreateMutable(); 
    CGPathMoveToPoint(pathToDraw, NULL, spriteA.position.x, spriteA.position.y); 
    CGPathAddLineToPoint(pathToDraw, NULL, spriteB.position.x, spriteB.position.y); 
    lineNode02.path = pathToDraw; 
    [self addChild:lineNode02]; 

    //Add Particles 
    myParticlePath = [[NSBundle mainBundle] pathForResource:_parName ofType:@"sks"]; 
    myParticleEmitter = [NSKeyedUnarchiver unarchiveObjectWithFile:myParticlePath]; 
    [self addChild:myParticleEmitter]; 

    CGFloat distancebtween = SDistanceBetweenPoints(spriteA.position, spriteB.position); 
    myParticleEmitter.particlePositionRange = CGVectorMake(particleLength,0); 
    myParticleEmitter.position = CGPointMake(distancebtween/2, +10); 
    self->myParticleEmitter.targetNode = self.scene; 

    int particleTime = 3; 
    SKAction *followTrack = 
    [SKAction followPath:pathToDraw 
    asOffset:YES 
    orientToPath:YES 
    duration:particleTime]; 

    SKAction *forever = [SKAction repeatActionForever:followTrack]; 
    self->myParticleEmitter.particleAction = forever; 
} 

在遊戲層

-(void)addStaticLinkedSpriteWithParticles 
{ 
    twoSpritesWithParticlesBridge = 
    [[LinkWithNumber alloc]initWithlinkSpriteA:@"Object" 
             spriteB:@"Object" 
          andPlistAnimation:@"Aniamtions" 
            distbetween:100 
            hasParticles:YES 
           ParticlesNamed:@"Fire"]; 
     [self addChild:self->twoSpritesWithParticlesBridge]; 
} 

謝謝:) 娜塔莉。

enter image description here

回答

0

最後,我去它的工作不需要再接可言。

  • 上SpriteA創建粒子系統的位置
  • 之間
  • 查找距離兩個精靈(以獲取粒子長度)
  • 調整顆粒的長度在發射極特性
  • 復位的 顆粒,使他們在兩個精靈之間居中

    if (isUsingParticles == YES) { 
    
    //create particles 
    myParticlePath = [[NSBundle mainBundle] pathForResource:_parName ofType:@"sks"]; 
    myParticleEmitter = [NSKeyedUnarchiver unarchiveObjectWithFile:myParticlePath]; 
    [self addChild:myParticleEmitter];//try moving it to the line node 
    
    //find length needed for particles 
    CGFloat distancebtween = SDistanceBetweenPoints(spriteA.position, spriteB.position); 
    
    //Adjust length of particles 
    myParticleEmitter.particlePositionRange = CGVectorMake(particleLength,0); 
    
    //center particles between the two sprites 
    myParticleEmitter.position = CGPointMake(spriteA.position.x+distancebetween/2, spriteA.position.y); 
    myParticleEmitter.targetNode = self.scene; 
    

    }

希望它可以幫助別人:)

相關問題