3

I'm currently working on an iphone application where there should be "Electrical power flows" visualised from a plug to a device.

I've made this a static line, but it would be way nicer if there was some way that those lines could be replaced by particles, showing an actual flow rather than a simple connection.

So for example device A is at position 100,50 and the plug is at position 200,300. I want particles to start emitting from 200,300 and 'flow' to point 100,50 and stop there.

I've concidered gravity, but as more than 1 device will be in the screen at the same time, this will probably be messed up?

Doing this staticly isn't a solution either: the devices can be moved around the screen and the particles should follow.

EDIT:

In the end a friend of me helped me out:

There is this point X1, y1 and point x2, y2

So to calculate the angle where to go to: dx = 100 - 200 dy = 50 - 300 speed = 100; alpha = arctan2(dy,dx)
distance = sqrt(dx*dx + dy*dy) set emittercell litetime = distance / speed set emittercell speed = speed set emittercel emissionlongitude = alpha

and done!

Xyclade
  • 31
  • 4
  • Do you need just "some motion" on the connection, or is there always a source and a target, i.e. a directed flow? – Eiko Oct 03 '12 at 15:27
  • There is always a source and a target So there will always be a "plug" and atleast 1 "device" (each represented by a uiimage) – Xyclade Oct 03 '12 at 16:08
  • So all particles move in a straight line from the plug to the device? How many particles are you planning to show on screen at the same time? Do the particles move freely or in along a power cord? – David Rönnqvist Oct 04 '12 at 20:13

1 Answers1

1

I think you need to investigate CAEmitterLayer layers. They should do what you want. Unfortunately, I've only read about them and never used them and so cannot provide any examples.

Link to CAEmitterLayer Class Reference

Robotic Cat
  • 5,899
  • 4
  • 41
  • 58