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 <Cocoa/Cocoa.h>
#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>
#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] ) > ( [cubeObject getX] - [cubeObject getR] ) ) && ( ( [shipObject getX] + [shipObject getR] ) < ( [cubeObject getX] + [cubeObject getR] ) ) )
{
<font color = green>if</font> ( ( ( [shipObject getY] + [shipObject getR] ) > ( [cubeObject getY] - [cubeObject getR] ) ) && ( ( [shipObject getY] + [shipObject getR] ) < ( [cubeObject getY] + [cubeObject getR] ) ) )
{
<font color = green>return</font> <font color = purple>YES</font>;
}
}
<font color = green>if</font>( ( ( [shipObject getX] - [shipObject getR] ) > ( [cubeObject getX] - [cubeObject getR] ) ) && ( ( [shipObject getX] + [shipObject getR] ) < ( [cubeObject getX] + [cubeObject getR] ) ) )
{
<font color = green>if</font> ( ( ( [shipObject getY] + [shipObject getR] ) > ( [cubeObject getY] - [cubeObject getR] ) ) && ( ( [shipObject getY] + [shipObject getR] ) < ( [cubeObject getY] + [cubeObject getR] ) ) )
{
<font color = green>return</font> <font color = purple>YES</font>;
}
}
<font color = green>if</font>( ( ( [shipObject getX] + [shipObject getR] ) > ( [cubeObject getX] - [cubeObject getR] ) ) && ( ( [shipObject getX] + [shipObject getR] ) < ( [cubeObject getX] + [cubeObject getR] ) ) )
{
<font color = green>if</font> ( ( ( [shipObject getY] - [shipObject getR] ) > ( [cubeObject getY] - [cubeObject getR] ) ) && ( ( [shipObject getY] + [shipObject getR] ) < ( [cubeObject getY] + [cubeObject getR] ) ) )
{
<font color = green>return</font> <font color = purple>YES</font>;
}
}
<font color = green>if</font>( ( ( [shipObject getX] - [shipObject getR] ) > ( [cubeObject getX] - [cubeObject getR] ) ) && ( ( [shipObject getX] + [shipObject getR] ) < ( [cubeObject getX] + [cubeObject getR] ) ) )
{
<font color = green>if</font> ( ( ( [shipObject getY] - [shipObject getR] ) > ( [cubeObject getY] - [cubeObject getR] ) ) && ( ( [shipObject getY] + [shipObject getR] ) < ( [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