【发布时间】:2015-02-24 17:13:09
【问题描述】:
我正在尝试创建一个横扫当前场景的横幅。我想创建一个横扫屏幕以显示当前回合的横幅。我的尝试是创建一个 UIImageView 并将其添加到当前视图中。但是,我假设它调用了 didMoveToView 函数并重置了该场景中的所有内容,这是我不希望它做的事情。这是我的尝试:
-(void)createBanner{
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Banner"]];
[imageView setFrame:CGRectMake(0,0, imageView.frame.size.width, imageView.frame.size.height)];
[imageView setClipsToBounds:YES];
[self.view addSubview:imageView];
CABasicAnimation *sweep = [CABasicAnimation animationWithKeyPath:@"position"];
sweep.fromValue = [NSValue valueWithCGPoint:CGPointZero];
sweep.toValue = [NSValue valueWithCGPoint:CGPointMake(0.0, self.frame.size.height)];
sweep.duration = 10;
sweep.additive = YES;
[imageView.layer addAnimation:sweep forKey:@"sweep"];
}
编辑:我正在使用精灵套件来创建游戏。
【问题讨论】:
-
您是否真的按照您的标签建议的那样制作 Sprite Kit 项目?如果是这样,那么你不应该使用 UIKit 来做这些。
-
您使用
self.view作为超级视图,self.frame作为您的最终位置。您可能希望将其更改为self.view.frame。 -
@hamobi 是的,我正在使用精灵套件来执行此操作。我觉得这不是正确的做法。你有什么建议?
标签: ios objective-c sprite-kit