I'm creating a game in objective-c and need to detect when two objects intersect frames.
I typically would detect this by using
if (CGRectIntersectsRect(object1.frame, object2.frame)) {/*do something*/}
My only issue is that I've created individual class files for each object. I have object1 in class1 and object2 in class2, so I can't access object1 in class2.
I tried passing the object as a parameter but received a strong id error, so I assume objects aren't allowed to be passed. How I can access the object1.frame in class2? I'm still new to objective-c, so I would appreciate any advice! Thanks in advance, let me know if you need any more information.
EDIT: Sorry for the ambiguity, I wasn't very clear. I declared a UIImageView or "object1" in class1.h and is used throughout the class1.m file.
I have another class where I declared another UIImageView "object2" in class2.h and class2.m. At one point during the class2.m file, I need to see if object1 and object2 are intersecting.
#importthe necessary class interface files?