私は cocos2d を使用していくつかのサンプル ゲームに取り組んでおり、より多くの練習を行っていますが、クラスに問題があります。これが私の例です:
someShapes.h
#import <Foundation/Foundation.h>
#import "cocos2d.h"
@interface palleteOfShapes : CCLayer
{
NSMutableArray *shapesArray;
}
@property (nonatomic,retain) NSMutableArray *shapesArray;
-(void)drawPallete;
@end
someShapes.m
#import "palleteOfShapes.h"
@implementation palleteOfShapes
@synthesize shapesArray;
-(void)drawPallete
{
shapesArray = [NSMutableArray arrayWithObjects:@"Icon.png",@"A.png",@"questionMark.png",nil];
for (int i=0; i<shapesArray.count; i++) {
NSString *imagestring = [shapesArray objectAtIndex:i];
CCSprite *sprite = [CCSprite spriteWithFile:imagestring];
NSLog(@"i value: %i",i);
sprite.position=ccp(100*i,350);
NSLog(@"image added:%@",imagestring);
[self addChild:sprite];
NSLog(@"count: %d",[shapesArray count]);
}
NSLog(@"pallete was completed");
[shapesArray removeLastObject];
NSLog(@"count:%d",[shapesArray count]);
}
@end
メインレイヤーで私は:
palleteOfShapes *newPallete = [[palleteOfShapes alloc]init];
[newPallete drawPallete];
これらのスプライトがメイン レイヤーに表示されることを期待していましたが、そうではありません。NSLog はすべてのメッセージを表示しますが、スプライトは表示しません。
できれば、何が悪いのか教えてください。前もって感謝します。