Working with Other Node Types

Working with Other Node Types

  

Shape Nodes Draw Path-Based Shapes

  The SKShapeNode class draws a standard Core Graphics path. 

  

You can see from the code that the shape has three essential elements:

  • The interior of the shape is filled. The fillColor property specifies the color used to fill the interior.
  • The outline of the shape is rendered as a line. The strokeColor and lineWidth properties define how the line is stroked.
  • A glow extends from the outline. The glowWidth and strokeColor properties define the glow.

A Video Node Plays a Movie

  The SKVideoNode class uses the AV Foundation framework to display movie content. 

 

Emitter Nodes Create Particle Effects

  When an SKEmitterNode object is placed in a scene, it automatically creates and renders new particles. You use emitter nodes to automatically create special effects, including rain, explosions, or fire.

A particle is similar to an SKSpriteNode object; it renders a textured or untextured image that is sized, colorized, and blended into the scene. However, particles differ from sprites in two important ways:

  • A particle’s texture is always stretched uniformly.
  • Particles are not represented by objects in Sprite Kit. This means you cannot perform node-related tasks on particles, nor can you associate physics bodies with particles to make them interact with other content.

Particles are purely visual objects, and their behavior is entirely defined by the emitter node that created them. The emitter node contains many properties to control the behavior of the particles it spawns, including:

  • The birth rate and lifetime the particle. You can also specify the maximum number of particles that are spawned before the emitter turns itself off.
  • The starting values of the particle, including its position, orientation, color, and size. These starting values are typically randomized.
  • The changes to apply to the particle over its lifetime. Typically, these are specified as a rate-of-change over time. For example, you might specify that a particle rotates at a particular rate, in radians per second. The emitter automatically updates the particle data each frame. In most cases, you can also create more sophisticated behaviors using keyframe sequences. For example, you might specify a keyframe sequence for a particle so that it starts out small, scales up to a larger size, then shrinks before dying.

Use the Particle Emitter Editor to Experiment with Emitters

  内置Particle模板,如下,通过File->Resource->SpriteKit Particle 来添加内置模板到应用程序。

  

  Inspector中可以修改Particle效果,立即生效。

  

  Particle Textrue用于修改粒子使用的texture,如下面两图使用了不同的ParticleTexture,

 

   

  Setting the Number of Particles Created

  

  Setting a Particle’s Life Expectancy

  

原文地址:https://www.cnblogs.com/tekkaman/p/3530503.html