Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Help! Missed Connections

Help! Missed Connections
Thread Tools
Forum Regular
Join Date: Jan 2001
Location: San Luis Obispo, California, USA
Status: Offline
Reply With Quote
Sep 22, 2001, 03:39 AM
 
Ok.... so I'm working on a little cocoa/opengl project.

Everything was going fine until a day ago.... I wrote in some very simple collision detection code. The collision detection didn't work at all, so I started debugging. The collision watcher uses an access method of my opengl objects to see what their coordinates are.

I put a breakpoint at the method that should return the X coordinate.

It never evaluates! The code sends the message, but just skips over it. What am I doing wrong? Here's some snippets of the code:

<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre><font size=1 face=courier>
collider.h :

#import &lt;Cocoa/Cocoa.h&gt;
#import &lt;Foundation/Foundation.h&gt;
#import &lt;AppKit/AppKit.h&gt;
#import <font color = red>"MyObject.h"</font>
#import <font color = red>"Cubeobject.h"</font>

<font color = purple>@interface</font> collider : NSObject
{
IBOutlet CubeObject *cubeObject;
IBOutlet MyObject *shipObject;
NSTimer *timer;

}

- (<font color = green>void</font>)init;
- (<font color = purple>BOOL</font>)didCollide;
- (<font color = green>void</font>)bounce;
- (<font color = green>void</font>)collideCheck;

<font color = purple>@end</font>

-----------------------------------------------
part of collider.m:


- (<font color = purple>BOOL</font>)didCollide
{
<font color = green>if</font>( ( ( [shipObject getX] + [shipObject getR] ) &gt; ( [cubeObject getX] - [cubeObject getR] ) ) && ( ( [shipObject getX] + [shipObject getR] ) &lt; ( [cubeObject getX] + [cubeObject getR] ) ) )
{
<font color = green>if</font> ( ( ( [shipObject getY] + [shipObject getR] ) &gt; ( [cubeObject getY] - [cubeObject getR] ) ) && ( ( [shipObject getY] + [shipObject getR] ) &lt; ( [cubeObject getY] + [cubeObject getR] ) ) )
{
<font color = green>return</font> <font color = purple>YES</font>;
}
}

<font color = green>if</font>( ( ( [shipObject getX] - [shipObject getR] ) &gt; ( [cubeObject getX] - [cubeObject getR] ) ) && ( ( [shipObject getX] + [shipObject getR] ) &lt; ( [cubeObject getX] + [cubeObject getR] ) ) )
{
<font color = green>if</font> ( ( ( [shipObject getY] + [shipObject getR] ) &gt; ( [cubeObject getY] - [cubeObject getR] ) ) && ( ( [shipObject getY] + [shipObject getR] ) &lt; ( [cubeObject getY] + [cubeObject getR] ) ) )
{
<font color = green>return</font> <font color = purple>YES</font>;
}
}

<font color = green>if</font>( ( ( [shipObject getX] + [shipObject getR] ) &gt; ( [cubeObject getX] - [cubeObject getR] ) ) && ( ( [shipObject getX] + [shipObject getR] ) &lt; ( [cubeObject getX] + [cubeObject getR] ) ) )
{
<font color = green>if</font> ( ( ( [shipObject getY] - [shipObject getR] ) &gt; ( [cubeObject getY] - [cubeObject getR] ) ) && ( ( [shipObject getY] + [shipObject getR] ) &lt; ( [cubeObject getY] + [cubeObject getR] ) ) )
{
<font color = green>return</font> <font color = purple>YES</font>;
}
}

<font color = green>if</font>( ( ( [shipObject getX] - [shipObject getR] ) &gt; ( [cubeObject getX] - [cubeObject getR] ) ) && ( ( [shipObject getX] + [shipObject getR] ) &lt; ( [cubeObject getX] + [cubeObject getR] ) ) )
{
<font color = green>if</font> ( ( ( [shipObject getY] - [shipObject getR] ) &gt; ( [cubeObject getY] - [cubeObject getR] ) ) && ( ( [shipObject getY] + [shipObject getR] ) &lt; ( [cubeObject getY] + [cubeObject getR] ) ) )
{
<font color = green>return</font> <font color = purple>YES</font>;
}
}

<font color = green>else</font>
{
<font color = green>return</font> <font color = purple>NO</font>;
}

------------------------------

part of MyObject.m :

- (<font color = green>float</font>)getX
{
<font color = green>return</font> x;
}

----------------------------------

</font>[/code]


Why isn't [shipObject getX] being evaluated?


Thanks,
Nathaniel Martin
nbmartin@calpoly.edu
     
robotic  (op)
Forum Regular
Join Date: Jan 2001
Location: San Luis Obispo, California, USA
Status: Offline
Reply With Quote
Sep 22, 2001, 08:28 PM
 
Clarification:

if I put in breakpoints, it does reach - (bool)didCollide:

But it skips over (float)getX.


-Nathaniel
     
   
Thread Tools
Forum Links
Forum 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
Top
Privacy Policy
All times are GMT -5. The time now is 12:19 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2