Reputation: 6085
I am writing a game in which a Uiimageview needs to be 'spawned,' if you will. every time the character hits the end box. Everything else is working except that. Could someone check my code and see what I'm doing wrong? Thanks!
for (int i = 1; i <= level; i++) {
int xPos = rand() % 316;
int yPos = rand() % 450;
UIImageView *mine = [[UIImageView alloc] initWithFrame:CGRectMake(xPos, yPos, 10, 10)];
}
Upvotes: 2
Views: 157
Reputation: 726479
You are not adding the views that you create in a loop as subviews to your main view. That's why they do not become visible.
As a side note, I think you would be better off using CALayer
objects instead of UIImageView
: they are lighter-weight, and require about the same amount of work.
Upvotes: 3