views:

590

answers:

1

I have a UIImageView that can be dragged around with a finger. It is sized to an image in it, such as a ball or square. If the user accelerates very quicker, I'd like to trail the object with a blur of itself to give the appearance of going fast. Like what happens with warp speed. I also have a swoosh sound. I'd like the sound to last only as long as the user is accelerating.

How can I accomplish these effects?

+1  A: 

Well, the sound is completely out of my skill-set - OpenGL has no support for sounds, you'd have to look into OpenAL or whatever equivalents exist on the iPhone.

A simple way to implement the blur is to keep an array of the last few points that the object has been. Whenever the UIImageView is moved (I'm not sure if there's an event, or if you have to check every frame), you push the new locations onto the array, deleting the oldest one.

Whenever it comes time to render the object, look at the last few points and calculate the distance between current position and the latest item in the array. If it's above a certain distance, draw a blur at the array location and check the next two points. Continue until the distance is below a certain amount.

Hope this helps!

Andrei Krotkov