xcode image coordinates
Ok im in the middle of making a game for iphone and i was wondering how to delete an image if it gets past a certain coordinate开发者_开发问答s. Im doing this strait in xcode. Also please post some example code. All help is appreciated.
Try
[imageView removeFromSuperview];
or, if you want it to come back later, just do
[imageView setHidden:YES];
Let's say you have a view aView
that you are moving around through code. Now let's say aRect
is a rectangle where aView
should be visible. If aView
moves outside of aRect
and you want to remove it, you can do something like this:
.... you move aView ....
if (!CGRectContainsRect(aRect, [aView frame])) {
[aView removeFromSuperview];
}
I should point out that this method only works if you are moving aView
with a timer or some such method. Otherwise something like this is slightly less trivial.
精彩评论