나는 사용자가 탭을 터치 할 때까지 버튼이 화면을 가로 질러 움직이는 게임을 만들고 있습니다. 지금까지 내가 가지고있는 것은 버튼이 무작위로 생성되는 것입니다. 내 문제는 새 단추가 만들어지고 마지막 단추가 움직이지 않을 때입니다. 나는 그들을 배열에 집어 넣으려고 노력하고 있지만, 실제로 움직이는 지 확신하지 못합니다.목표 C : 변경 가능한 배열 내에서 버튼 작동
-(void) generateStickFig:(NSTimer *)timer {
int x = random() % 100;
NSMutableArray *enemies = (NSMutableArray *)timer.userInfo;
if (x == 1) {
stickFig = [[UIButton alloc] initWithFrame:CGRectMake(0, 650, 50, 50)];
[stickFig setBackgroundColor:[UIColor blackColor]];
[stickFig addTarget:self action:@selector(tapFig:) forControlEvents:UIControlEventTouchUpInside];
// [enemies setObject:object forKey:[NSString stringWithFormat:@"object%i",i]];
[enemies addObject:stickFig];
int b = [enemies count];
[self.view addSubview:stickFig];
arrayNum++;
}
CGPoint oldPosition = stickFig.center;
stickFig.center = CGPointMake(oldPosition.x + 1 , oldPosition.y);
}
하지만 내가 가지고있는 같은 문제. 어떻게하면 별개의 단추인지 알 수 있습니다. – Chris
내 편집 내용이 더 명확하게 보이는지 확인하십시오. –