我創建了一個SKEmitterNoder(標準Fire.sks模板)&將它添加到一個名爲ball的SKSpriteNode中。事情是,我按照教程&的方式跟隨了iOS Games的教程,他們教我創建平鋪地圖的方式,實質上是在初始化時將它們翻轉,以便(0,0)將位於屏幕的左下角& NOT top left 。我認爲這影響了我的SKEmitterNode targetNode屬性,因爲當球在場景中移動時,火焰發射器節點的方向完全相反。有人能告訴我該怎麼做才能改變這種情況嗎?我無法改變世界參數,所以我需要改變SKEmitterNode軌跡的東西,以便它實際上正確地跟隨球節點。這是我目前的代碼:SKEmitterNode targetNode路徑被反轉
NPCBall *ball = [[NPCBall alloc] initWithBallType:BallTypeRed andName:@"Ball Red"];
ball.position = CGPointMake(x + w/2, y + h/2);
ball.zPosition = -104.0;
[_entityNode addChild:ball];
//Create a random Vector.dx & dy for the NPC. This will apply a random impulse to kick start NPC non-stop movement.
[ball.physicsBody applyImpulse:CGVectorMake([self randomVectorGeneration].dx, [self randomVectorGeneration].dy)];
//Create a particle for the ball (fire).
SKEmitterNode *emitFire = [NSKeyedUnarchiver unarchiveObjectWithFile:[[NSBundle mainBundle] pathForResource:@"Particle_Fire" ofType:@"sks"]];
emitFire.position = CGPointMake(ball.position.x, ball.position.y);
emitFire.targetNode = ball;
[_entityNode addChild:emitFire];
P.S. _entityNode,其中球& SKEmitterNode火添加,是一個SKNode。這又是SKNode的一個名爲_worldNode的孩子。 _worldNode是自己的孩子(這是SKScene)。這個_worldNode是翻轉後有(0,0)座標從左下角開始的。