• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
OpenGL Sprites...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

OpenGL Sprites...


  • Subject: OpenGL Sprites...
  • From: Albert Atkinson <email@hidden>
  • Date: Mon, 24 Jun 2002 11:21:56 -0500

I am trying to update one of my sprites to show another image when the up arrow key is pressed. Here is a snippet of code:

case upKey:
if(released) {
upKeyPressed = NO;
spriteImage = [[NSImage alloc] initWithContentsOfFile: fileName];
} else {
upKeyPressed = YES;
spriteImage = [[NSImage alloc] initWithContentsOfFile: fileNameThrust];
}
break;

At the top of my code file is this snippet:

NSBundle *programBundle = [NSBundle bundleForClass:[self class]];

fileName = [programBundle pathForResource:@"Apple" ofType:@"tiff"];
fileNameThrust = [programBundle pathForResource:@"Apple Thrust" ofType:@"tiff"];
spriteImage = [[NSImage alloc] initWithContentsOfFile: fileName];

And here is my header file:

#define upKey 126

//Some code snipped out...

BOOL upKeyPressed;

NSString *fileName;
NSString *fileNameThrust;

//Some code snipped out...

- (id)init;
- (void)dealloc;
- (void)update;
- (void)handleKey:(unsigned short)key keyUp:(BOOL)released;

My problem is that when I run the app it will work fine but the moment I push the up arrow I crash. Any suggestions?

Thanks!

Albert
_______________________________________________
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.

  • Follow-Ups:
    • Re: OpenGL Sprites...
      • From: Markus Hitter <email@hidden>
  • Prev by Date: Re(2): How to get notified on PPP connect/disconnect?
  • Next by Date: NSFileWrapper (directory wrapper) and Document Architecture
  • Previous by thread: Re: Dealloc method needed?
  • Next by thread: Re: OpenGL Sprites...
  • Index(es):
    • Date
    • Thread