Cocoa Touch - Floating Image bouncing across screen - iphone

I need help with making a UIImageView float on the screen and when it hits the walls it bounces off like collision detection..
I havent gotten further than making the imageview. I need some help..
Any help? Thanks!

What is the best way to make a bouncing ball animation with infinite loop on iPhone?

Related

Detecting touches on a UIImageView in IPhone

I'm programming a King Chess game on the iPhone. When the user touches a square on the screen, I want to know which square was selected.
I am using UIImageViews to show squares on the screen.
UIImageview would not be feasible in your scenario. You can use UIButton with customtype and assign image to that button. So it looks like button but you can add target and you know which square touch/pressed.
Hope this help.
in touchesEnded: method , u can get the position of ur touch.
Then , u go thru all the image views (squares) , comparing their frame positions using CGRectIntersectsRect and find which square is touched.

Looking for direction for a Custom Gesture like swipe to scroll

I'm trying to have a sort of gesture that will seamlessly switch between a group of images this part I have sorted. The part that is catching me up is the gesture to do so and how I might introduce acceleration.
Basically the user would swipe as normal and after the swipe is registered it would change the image displayed and the faster once swiped the faster the image would change ideally it would then keep that speed until the users finger was lifted leaving the possibility to just scroll repeatedly through the images.
Any direction someone could give me would be great.
Thanks.
Assuming you would be using a UIScrollView for this, setting the scrollView.decelerationRate property would allow you to manipulate the deceleration rate/scroll speed. To calculate the "swipe speed", take a look here: Detecting Special touch on the iphone for some pointers.

Cocos2D, UIScrollView, and initial placement of a scene

I am using a UIScrollView to forward touches to Cocos2D as outlined in http://getsetgames.com/2009/08/21/cocos2d-and-uiscrollview/
Everything works great after a few days of working with it, except one thing: when the initial view appears on the screen, the background appears to be scrolled to the center. As soon as I try to scroll around, the image jumps to 0,0, and everything works as normal, except the touches are offset by half the width and height of the background image. Am I overlooking something basic? I can't think of a useful portion of the code that illustrates the issue, as I can't track it down, but would be happy to post code if anyone has any ideas.
Thanks in advance,
-Roberto
I just had to localize the touches in respect to the window, by using nil in locationInView. This returns the touch's location on what's currently visible in the display.
CGPoint location = [[CCDirector sharedDirector] convertToGL:[touch locationInView:nil]];

Rotate a UIImageView with a touch gesture - iphone dev

Been having real trouble with this one and wondered if someone may have found a solution to this issue.
I would like to be able to rotate a UIImageView using a touch gesture
-> So when the user places two fingers on the touch area and rotates their fingers the UIImageView will rotate with them (Rotating in whatever direction the user moves their fingers)
I can do this but with one issue.... as the UIImageView rotates it does not keep its shape. It seems to skew?? It is really strange and i can not understand why it is happening.
So if i start with an equal sided square... as i rotate it does not remain as an equal sided square the sides seem to skew and not remain equal.
SOOOO i was wondering if anyone has come across this issue, or if anyone has successfully rotated a UIImageView with a touch gesture without it skewing.
Any help regarding this issue is highly appreciated.
Cheers
Tom
Can you give us some more information, like the rotation code?
Hopefully you're doing something like the following:
[imageView setTransform: CGAffineTransformMakeRotation(M_PI/2)];

How much a UIImageView rotated?

I have an UIImageView that is being pinched, zoomed, rotated, etc. When the user ends transforming the image he presses the DONE button and I have to figure out how much the object was scaled and rotated.
All I know is the angle and scale of the object before the user started modifying it. Now I need the new angle and scale.
How to do that? If you can point to a code, it will help.
thanks
I suggest to keep a track of all changes made.
If the user pinches zooms,etc, it means that the app will calculate the rotation and zooming for every touch the user does right?
So, Why don't use the last touch to know the rotation and zoom?
You could update your zoom and rotation variable every time the user does a touch.
Regards
Ignacio