[英]NSTimer to move image
I have an large image I have put in an image view. 我在图像视图中放了大图像。 the image view is larger than the screen, and i set it up to move in diagonal downwards at a certain speed.
图像视图大于屏幕,我将其设置为以一定速度向下倾斜移动。
the image does move, but at a certain point we see the white because the image has slider away. 图像确实会移动,但是在某个点上我们会看到白色,因为图像已经滑开了。 I would like to continue sliding the image like if it was a globe.
我想继续像滑动地球一样滑动图像。 or at least change the direction to opposite.
或至少将方向更改为相反方向。 I tried this:
我尝试了这个:
- (void) onTimer {
palla.center = CGPointMake(palla.center.x+1, palla.center.y+1);
if (palla.center.x > -20000||palla.center.x < 20000){
CGPointMake(palla.center.x-1, palla.center.y+-1);
}
unfortunately it does not work. 不幸的是,它不起作用。 I even tried pos, but still does not work.
我什至尝试过pos,但仍然无法正常工作。 how can I fizx this?????
我该如何解决这个问题???? please help, I can't find any tutorials online
请帮助,我在网上找不到任何教程
You can try this. 你可以试试看 I have written with iphone in mind.
我在写iphone时就牢记在心。 "image" is the image view.
“图像”是图像视图。
-(void)onTimer
{
CGRect imageRect = image.frame;
if (CGRectContainsPoint(CGRectMake(0, 0, 320, 460), image.center))
{
image.center = CGPointMake(image.center.x + 50, image.center.y + 50);
}
else
{
image.frame = CGRectMake(0, 0, imageRect.size.width, imageRect.size.height);
}
now animate both the way you are doing..keeping the 现在为您的做事方式设置动画。
second origin = first image view.origin - image view.frame.width. 第二个原点=第一个图片view.origin-图片view.frame.width。
When a view goes out of the screen..place it behind of other. 当视图离开屏幕时..将其置于其他视图的后面。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.