Collision problem solved (sorta...)
Collision problem solved (sorta...)
- Subject: Collision problem solved (sorta...)
- From: Mike Brinkman <email@hidden>
- Date: Tue, 14 May 2002 18:05:11 -0400
My code now can tell if it hit a brick, but while using the debugger I
noticed something very interesting. I've changed the Struct that defines a
brick type a little to look as such:
typedef struct _brick{
NSRect r;
NSBezierPath *bp;
BOOL active;
NSColor *color;
}brick;
I also declare an array
brick myBrick[120];
in the interface file.
Now here's the interesting thing. In my collision detection method, I have a
some code that looks like this:
// release the affine transformation
[at release];
at = [[NSAffineTransform transform] retain];
[at translateXBy:dx yBy:dy];
[[NSSound soundNamed:@"Pong2003"] play];
// change the brick
myBrick[n].color = [NSColor blackColor];
[myBrick[n].color set];
[myBrick[n].bp fill];
myBrick[n].active = NO;
break;
When I step into my code, myBrick[n].color gets set to black, and
myBrick[n].active get set to NO, but when I continue execution, the next
time around the values go back to their initial values. Why are my values
reverting to their initial values instead of changing to their new values?
I'm not sure if this is a problem with Cocoa or not, since I'm mixing Cocoa
with C...
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.