I am setting an index within a sprite sheet based on reading each character in a string of text.
So @"ABC" returns 12,13,14 and so on... The code below works but is there a simple (better) way of doing this?
I seems to remember CHR$() and the such like from BBC BASIC but I am struggling to find anything like that for NSString.
Hope someone can help 
So @"ABC" returns 12,13,14 and so on... The code below works but is there a simple (better) way of doing this?
I seems to remember CHR$() and the such like from BBC BASIC but I am struggling to find anything like that for NSString.
Code:
//default to char space
spriteTextureX[s]=38;spriteTextureY[s]=2;spriteTextureS[s]=textureSize32;//NOT default 128
if(messageCharPos<messageLen){
NSString *aChar = [messageText substringWithRange:NSMakeRange(messageCharPos, 1)];
//NSLog(@"char at pos %i is %@",messageCharPos,aChar);
if([@"A" isEqualToString:aChar]) {spriteTextureX[s]=12;}
if([@"B" isEqualToString:aChar]) {spriteTextureX[s]=13;}
if([@"C" isEqualToString:aChar]) {spriteTextureX[s]=14;}
// and so on...
messageX+=32;//inc x
messageCharPos++;//inc pos along the string
}//endif within len of string
Last edited: