나는 타이머를 기반으로 적의 스프 라이트를 부활 시키길 원한다. 어떤 제안이라도 인정 될 것이다. 몇 가지 코드 예제를 보여 주면 좋을 것입니다.타이머를 기반으로하는 cocos2d에서 시스템 복원을 설정하는 방법은 무엇입니까?
-(void)addEnemyAtX:(int)x y:(int)y {
CCSprite *enemy = [CCSprite spriteWithFile:@"enemy1.png"];
enemy.position = ccp(x, y);
[self addChild:enemy];
[self animateEnemy: enemy];}
- (void) enemyMoveFinished:(id)sender {
CCSprite *enemy = (CCSprite *)sender;
[self animateEnemy: enemy];
}// a method to move the enemy 10 pixels toward the player
- (void) animateEnemy:(CCSprite*)enemy
{
// speed of the enemy
ccTime actualDuration = 0.3;
// Create the actions
id actionMove = [CCMoveBy actionWithDuration:actualDuration
position:ccpMult(ccpNormalize(ccpSub(player.position,enemy.position)), 10)];
id actionMoveDone = [CCCallFuncN actionWithTarget:self
selector:@selector(enemyMoveFinished:)];
[enemy runAction:
[CCSequence actions:actionMove, actionMoveDone, nil]];
}
[자기 일정 : @selector (산란 : 간격 : 1.0F] 다른 모든 것은 구현에 따라 다르므로 스프라이트를 생성하는 방법 (규칙, 조건 등)에 대해서는 자세히 설명하지 않습니다. – LearnCocos2D
적의 시작 지점과 똑같은 지점에서 스폰하기를 원합니다. 무제한의 스프라이트가 있기를 원하고 새로운 스프라이트가 15 초간 만들어 지길 바란다. 나는 적의 코드를 게시 할 것이다. –
많은 스프라이트가 있습니다. 배치 노드를 사용하고 자주 사용하지 않는 노드를 제거하십시오. 그렇지 않으면 심각한 성능 문제가 발생할 것입니다. – tallen11