Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 01-02-2012, 07:18 PM   #1 (permalink)
Registered Member
 
Join Date: Mar 2011
Posts: 35
Kenenth is on a distinguished road
Default detect colliding Animated UIImageViews

In my current project, I have two different arrays of objects. I am trying to figure out a way to detect collision between one object in each array. I tried using CGRectIntersectsRect, but it doesnt seem to work. Any Ideas?

all objects are moved by this method:

Code:
[UIView beginAnimations:nil context:(UIImageView *)newObject];
		[UIView setAnimationDelegate:self];
		[UIView setAnimationDidStopSelector:@selector(objectmovefinish:finished:context:)];
		[UIView setAnimationDuration:3.0];
		[UIView setAnimationCurve:UIViewAnimationCurveLinear];
		newobject.center = CGPointMake(54, 200);
	    [UIView commitAnimations];
Kenenth is offline   Reply With Quote
Old 01-03-2012, 01:55 PM   #2 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
Join Date: Aug 2008
Location: Memphis, TN, USA
Age: 24
Posts: 3,983
smithdale87 is on a distinguished road
Send a message via AIM to smithdale87
Default

I believe if you want to do this, you'll need to animate the imageviews manually -- that is, set up an NSTimer and change the imageview frame when the timer is fired.

Then, with each iteration of the timer, you can also do your collision checking. The problem with UIAnimations is that the frame property is not updated during the animation.
smithdale87 is offline   Reply With Quote
Old 01-04-2012, 03:00 AM   #3 (permalink)
Registered Member
 
Join Date: Nov 2009
Location: Helsinki
Posts: 304
fiftysixty is on a distinguished road
Default

Quote:
Originally Posted by smithdale87 View Post
I believe if you want to do this, you'll need to animate the imageviews manually -- that is, set up an NSTimer and change the imageview frame when the timer is fired.

Then, with each iteration of the timer, you can also do your collision checking. The problem with UIAnimations is that the frame property is not updated during the animation.
The way Core Animation works is to have three "layers" (I suggest looking at Core Animation Rendering Architecture): There is the layer tree, presentation tree and render tree. When you make changes or commit animations, the final values are instantly applied to the layer tree. The presentation tree contains, at all times, the values used by the render tree. The "problem" in hit detection is that the UIView geometry properties return the layer tree values, and we'd need the presentation tree values to detect hits and collisions. Fortunately, it's easy enough to get them: UIView's layer property returns the CALayer for the view, and the CALayer's presentationLayer property return the presentation layer used, which contains the current, proper values.
fiftysixty is offline   Reply With Quote
Reply

Bookmarks

Tags
animation, objective-c, uiimageview, xcode

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 399
12 members and 387 guests
buggen, EvilElf, guusleijsten, j.b.rajesh@gmail.com, LunarMoon, morterbaher, QuantumDoja, sacha1996, Sami Gh, tim0504, VinceYuan
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,673
Threads: 94,122
Posts: 402,907
Top Poster: BrianSlick (7,990)
Welcome to our newest member, morterbaher
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 05:32 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0