Giter VIP home page Giter VIP logo

shootingstars's Introduction

ShootingStars

Some fun Shooting Star animations built with both SpriteKit and CAEmitterLayer. Run the example project to see both in action.

There are 2 ways to achieve a shooting star animation, which travels along a defined path while emitting particles. There are both some advantages, and disadvantages for each method.

Sprite Kit Example

sprite-kit-star

Advantages

  • Particle emitters are much more flexible. You can attach a targetNode to your sprite's emitter, which allows your particles to become independent of the sprite, thus not moving along the same path as the sprite. This is not as easily achievable using CAEmitterLayer
  • Sprite Particles (.sks files in Xcode) come with a very nice preview playground, where you can tweak values of the particles and see the changes real-time, and not have to keep restarting your app to see the changes.
  • End result seems much smoother

Disadvantages

  • You must add a SKView and associated SKScene on top of your view. SKScene's have very different coordinate systems than regular UIViews. Read more from Apple here. This means you may carefully translate coordinates from a UIView to a SKScene
  • Performance wise, using Sprite Kit seems to lag much easier (at least with this example). For example, in the sample, try to shoot off 5 SpriteKit stars, and then shoot off 5 Core Animation stars. You'll notice a lot of lag on the SpriteKit star, but not much on the CoreAnimation star

Core Animation Example

sprite-kit-star

Advantages

  • You don't need to worry about thinking about converting coordinates to a points in a SKScene, or worry about adding a SKView on top of your current UIView
  • Performance (at least for this example) seems much better. You can shoot off many CA stars with little to no lag

Disadvantages

  • Emitters do not have a nice playground where you can easily tweak settings and see the result real time. You must either keep restarting your app, or purchase an app that allows you to tweak settings and see the result real time.
  • Emitter particles, when attached to a UIView, follow the same path the UIView does, resulting in some ugly animations of your UIView does lots of turns with particles.

TODO:

  • Swift Example

shootingstars's People

Contributors

ryang1428 avatar

Watchers

James Cloos avatar Harold Bierlein avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.