快速滚动背景
我想要一个以与 UItableView 类似的方式滚动背景的游戏。我用一个计时器解决了这个问题,该计时器向上移动背景并将同一张图片的另一个副本向上移动,
if (bg1.center.y <= - self.view.bounds.size.height/2 ) {
bg1.center = CGPointMake(bg1.center.x, 690);
}
if (bg2.center.y <= - self.view.bounds.size.height/2 ) {
bg2.center = CGPointMake(bg2.center.x, 690);
bg1.center = CGPointMake(bg1.center.x, bg1.center.y - movement);
bg2.center = CGPointMake(bg2.center.x, bg2.center.y - movement);
但是我移动图片的速度越快,出现的问题就越多:背景之间出现间隙,并且移动速度越快,它们就会变得越大!移动是由在屏幕上滑动的速度定义的
有解决这个问题的想法吗?
i want a game that scrolls the background in a similar way to a UItableView. I solved it with a timer that moves the background up and brings another copy of the same picture up
if (bg1.center.y <= - self.view.bounds.size.height/2 ) {
bg1.center = CGPointMake(bg1.center.x, 690);
}
if (bg2.center.y <= - self.view.bounds.size.height/2 ) {
bg2.center = CGPointMake(bg2.center.x, 690);
bg1.center = CGPointMake(bg1.center.x, bg1.center.y - movement);
bg2.center = CGPointMake(bg2.center.x, bg2.center.y - movement);
But the faster i move the pictures the more problems occur: There are appearing gaps between the backgrounds and they are getting biggiger the faster i move them! movement is defined by the speed of swiping over the screen
Any idea to solve that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以尝试使用canvas元素
You could try using the canvas element