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

View Single Post
Old 03-19-2010, 12:27 PM   #6 (permalink)
smasher
Registered Member
iPhone Dev SDK Supporter
 
smasher's Avatar
 
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 3,858
smasher will become famous soon enough
Default

Quote:
Originally Posted by iSdkDev View Post
@SMASHER OR ANY1ELSE "Ok soo i did this code and i have those images falling but there's a bug!I have a label that turns to 1 from 0 when that falling image collides with an image below BUT there is a bug when i starts falling down it just automatically adds 1 to my label where as i want tht 1 to add only when it collides!!Please help"
Here is the code
First, all of this [self performSelector] is not necessary. Just call [self change] and [self change1] . If that gives you warnings, then you're not declaring your methods in the .h like you should. That's probably not causing this problem, but it'll make everything more readable and save you other trouble.

Your CGRectIntersectsRect code looks OK. Do cloud and banana have the same immediate parent view, or is one of them the subview of some other subview? That would keep the frames from being compared correctly -- one would be in the wrong coordinate space.

If that's OK, then log the frames and tell me what you're getting.

Code:
if(CGRectIntersectsRect(cloud.frame, banana.frame)) {

NSLog(@"cloud %f,%f  %f,%f", cloud.frame.origin.x, cloud.frame.origin.y, cloud.frame.size.width, cloud.frame.size.height);

NSLog(@"banana %f,%f  %f,%f", banana.frame.origin.x, banana.frame.origin.y, banana.frame.size.width, banana.frame.size.height);

     [self change];

     mainInt += 1;
     label.text = [NSString stringWithFormat:@"%d" , mainInt];
     [self UpdateINT];
}
Also make sure this bit of code is really the problem; comment out mainInt+=1 and make sure the problem goes away.
__________________

Free Games!

Last edited by smasher; 03-19-2010 at 12:29 PM.
smasher is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 175,546
Threads: 94,071
Posts: 402,695
Top Poster: BrianSlick (7,989)
Welcome to our newest member, icetee0527
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:45 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.