开发者

xcode image coordinates

开发者 https://www.devze.com 2023-03-22 03:30 出处:网络
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 ex

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消