2011-05-10 5 views
0

all.CCMoveTo는 내 CCSprites에 영향을주지 않습니다.

-(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]; 
} 

을하지만 그것은 작동하지 않습니다이다 : 나는 테트리스를 이동하려면이 기능의 일부 기능 "tetrisl"가 아래로 스프라이트. 동일한 액션에서 다른 스프라이트를 이동하려고하기 때문에 생각합니다. 어떻게 해결할 수 있습니까? 여기

감사

는 다른 스프라이트 한 조치를 할당 할 수 없습니다 테트리스 클래스

@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]; 
} 
+0

다른 ? 스프라이트가 장면에 추가되지 않습니까? 나타나지만 이동하지 않습니까? – mbehan

+0

예, 나타나지만 움직이지 않습니다. –

+0

테트리스 클래스와 createL 메소드에 대한 자세한 정보를 제공 할 수 있습니까? – KDaker

답변

0

입니다. 하나의 액션 - 하나의 스프라이트. 조치 복사 기능을 사용하여 조치를 Dublicate 할 수 있습니다.

하지만 액션이 루프에서 생성되므로 다른 동작을해야합니다 ... 다른 곳에서는 문제가 될 수 있습니다. 당신이 다음 코드와 같이 액션을 복사해야하므로

0

Defferent 스프라이트는 동시에 같은 동작을 실행 두지 : 당신이 그 코드를 실행할 때 작동하지, 무슨 일이 실제로 일어나고있는 것보다

sprite->runAction((CCActionInterval*)aciotn->copy->autoRelease()); 
관련 문제