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

Mockup & CodeGen, iPhone & iPad
($9.99)

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

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

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

Reply
 
LinkBack Thread Tools Display Modes
Old 02-04-2010, 07:50 AM   #1 (permalink)
Registered Member
 
Join Date: Oct 2009
Location: India
Posts: 11
Default Falling Image Collision Problem

Hi
Okay so i have a game & i want that random images should fall from top of the screen to the bottom & when it collides with an image that is already placed CGRect collision should happen.So how should i make images fall & apply CGRect.Please can you help me?

Thanks
Peace
iSdkDev is offline   Reply With Quote
Old 02-04-2010, 08:42 AM   #2 (permalink)
Registered Member
 
Join Date: Nov 2009
Location: Chicago
Posts: 29
Default

Apply a downward velocity to your object's location and then check for collisions with other objects.
DaveM is offline   Reply With Quote
Old 02-05-2010, 08:39 AM   #3 (permalink)
Registered Member
 
Join Date: Oct 2009
Location: India
Posts: 11
Default Hi,plz help

Quote:
Originally Posted by DaveM View Post
Apply a downward velocity to your object's location and then check for collisions with other objects.
Can you explain it in a better way with an example please?
iSdkDev is offline   Reply With Quote
Old 02-06-2010, 05:42 PM   #4 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
smasher's Avatar
 
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 3,858
Default

These two threads should help you out:
Random rocks:
iPhone Dev SDK Forum - Powered by vBulletin

Adding Stopped blocks:
iPhone Dev SDK Forum - Powered by vBulletin

If you tried that and it didn't work, please say what part didn't work.
__________________

Free Games!
smasher is offline   Reply With Quote
Old 03-19-2010, 05:34 AM   #5 (permalink)
Registered Member
 
Join Date: Oct 2009
Location: India
Posts: 11
Default @Smasher Collision Problem

//UnViewAble Content//

Last edited by iSdkDev; 03-20-2010 at 03:32 AM.
iSdkDev is offline   Reply With Quote
Old 03-19-2010, 01:27 PM   #6 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
smasher's Avatar
 
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 3,858
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 01:29 PM.
smasher is offline   Reply With Quote
Old 03-20-2010, 04:47 AM   #7 (permalink)
Registered Member
 
Join Date: Oct 2009
Location: India
Posts: 11
Default @Smasher Collision Problem

The [self change] or [self change1] is just for the game loop and
No everything is in one view, there are no subviews or
Parent views in the game play!!Now what 2 do?
iSdkDev is offline   Reply With Quote
Old 03-20-2010, 12:07 PM   #8 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
smasher's Avatar
 
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 3,858
Default

Quote:
Originally Posted by iSdkDev View Post
The [self change] or [self change1] is just for the game loop and
No everything is in one view, there are no subviews or
Parent views in the game play!!Now what 2 do?
Log the frames using the NSLog lines I wrote, and tell me what you're getting. Did you temporarily comment out mainInt+=1 and make sure the problem goes away? You want to make sure we're looking in the right place.
__________________

Free Games!
smasher is offline   Reply With Quote
Reply

Bookmarks

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: 268
18 members and 250 guests
ADY, Alsahir, dacapo, Dani77, Desert Diva, djohnson, Duncan C, F_Bryant, Grinarn, HemiMG, jansan, linkmx, M@realobjects, macquitzon216, prchn4christ, smethorst, spiderguy84
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,882
Threads: 89,228
Posts: 380,762
Top Poster: BrianSlick (7,129)
Welcome to our newest member, jansan
Powered by vBadvanced CMPS v3.1.0

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