How to create a wind effect in spritekit

I played with angry birds and arrived at this stage, where the wind "blows", and you push it. it was curiously interesting, but I really could not understand the logic or code that would do this. I know that you could probably use an emitter to create a wind like β€œwatching,” but I would really like to know how you handle the β€œpush” of a sprite.

thank

+3
source share
1 answer

You are right that the radiator can be used only for the illusion that the wind is blowing.

I assume that you have physical bodies attached to nodes that should be affected by the wind.

In your -update: method,

-(void)update:(CFTimeInterval)currentTime
{

    if (windOn)
    {
        for (SKNode *node in self.children)
        {
            if (node.physicsBody.categoryBitMask == whateverCategory)
            {
                [node.physicsBody applyForce:CGVectorMake(200, 0)];
            }
        }
    }
}  

, . .

+8

All Articles