I have to make an array with images in them and then check if another image collides with them.
So far I have try’d:
NSMutableArray *platforms = [NSMutableArray array];
[platforms addObject:platform1];
[platforms addObject:platform2];
[platforms addObject:platform3];
[platforms addObject:platform4];
[platforms addObject:platform5];
[platforms addObject:platform6];
[platforms addObject:platform7];
[platforms addObject:platform8];
for (platforms in platforms) << code not working needs to do this for the amount of platforms in the array
{
if(CGRectIntersectsRect(ball.frame, platforms.frame))
{
}
}
Though this code does not work.
Are there any other ways to do this?
The problem is your array consists of
UIImages. You need to addUIImageViewsfor implementing such a task.There is no frame property for
UIImage.Add the
UIImageViewsinstead of theUIImage.And change the code like: