Hello everyone,
I've been working on my game for the last week and all was well until I ran it on the iphone at which point it came to a grinding halt.
I narrowed the issue down to the following:
What I'm doing is creating an 8x8 array of UIImageView's and outputting them in a game loop that is fired every 1/60 of second via a timer in viewDidLoad.
My definition in the interface is:
UIImageView *_piece[8][8];
UIImage *piece;
viewDidLoad: piece = [UIImage imageNamed"white1.png"];
In the loop I have the following code:
From what I understand, I should be removing the view, assigning an image, positioning it, adding it to the view, and releasing it. In essence, completely removing all UIImageviews and then adding them back in. It works great in the simulator, but comes to a grinding halt on the actual device. Any help would be greatly appreciated.
-M
I've been working on my game for the last week and all was well until I ran it on the iphone at which point it came to a grinding halt.
I narrowed the issue down to the following:
What I'm doing is creating an 8x8 array of UIImageView's and outputting them in a game loop that is fired every 1/60 of second via a timer in viewDidLoad.
My definition in the interface is:
UIImageView *_piece[8][8];
UIImage *piece;
viewDidLoad: piece = [UIImage imageNamed"white1.png"];
In the loop I have the following code:
Code:
float startx = 15.0;
float starty = 30.0;
for(int i = 0;i < 8; i++) {
for(int j = 0; j < 8; j++) {
// remove previous view
[_piece[i][j] removeFromSuperview];
// assign image - same image for simplicity
_piece[i][j] = [[UIImageView alloc] initWithImage: piece];
// x and y of where to place the image
_piece[i][j].center = CGPointMake(startx,starty);
// add it to the view
[self.view addSubview:_piece[i][j]];
// release it
_piece[i][j].release;
startx += 36.0;
}
startx = 15.0;
starty += 36.0;
}
From what I understand, I should be removing the view, assigning an image, positioning it, adding it to the view, and releasing it. In essence, completely removing all UIImageviews and then adding them back in. It works great in the simulator, but comes to a grinding halt on the actual device. Any help would be greatly appreciated.
-M