все. У меня есть некоторая функция "tetrisl" в этой функции. Я хочу переместить спрайты тетриса вниз:
-(void)tetrisL:(ccTime)dt {
Tetris *s = [[Tetris node]initWithArraySize:4];
[s createL];
for (CCSprite *new in s.tetrisArray) {
[self addChild:new];
id actionMove = [CCMoveTo actionWithDuration:3 position:ccp(new.position.x,0)];
[new runAction: actionMove];
}
[s release];
}
Но это не работает. Я думаю, потому что я пытаюсь перемещать разные спрайты в одном действии. Как я могу это исправить? Спасибо
Вот класс Тетрис
@interface Tetris : CCNode {
NSMutableArray *tetrisArray;
Blocks *tempBlock;
}
@property (nonatomic, retain) NSMutableArray *tetrisArray;
@property (nonatomic, retain) Blocks *tempBlock;
-(id)initWithArraySize:(int)sz;
-(void)createL;
@implementation Tetris
@synthesize tetrisArray;
@synthesize tempBlock;
-(id)initWithArraySize:(int)sz {
if( (self=[super init] )) {
tetrisArray = [[NSMutableArray alloc]initWithCapacity:sz];
}
return self;
}
-(void)createL {
int xPos = 10;
int yPos = 460;
for (int i = 0; i < 4; i++) {
tempBlock = [[Blocks node]initWithType:1];
tempBlock.blockSprite.position = ccp(xPos,yPos);
[tetrisArray addObject:tempBlock.blockSprite];
xPos = xPos + 26;
[tempBlock release];
}
}
-(void)dealloc {
[tempBlock release];
[tetrisArray release];
[super dealloc];
}