不使用cocos 2D是否可以有粒子。我知道粒子设计器,但我们必须将它与 cocos 2D 一起使用。没有cocos 2D如何制作粒子?
最佳答案
您可以通过生成图像并将其添加到数组中来完成此操作,这使得为图像设置动画或对其执行任何操作变得非常容易。
- (void)createImage {
UIImageView *Image = [[UIImageView alloc] initWithFrame:CGRectMake(arc4random() % 320, 480, 40, 40)];
[Image setBackgroundColor:[UIColor blackColor]];
[self.view addSubview:Image];
[myArray addObject:Image];
}
这会在任意位置创建一个黑色图像并将其添加到数组中。
然后,您可以创建一个计时器并每秒生成图像!
spawn = [NSTimer scheduledTimerWithTimeInterval:1.0/3 target:self selector:@selector(Spawn) userInfo:nil repeats:YES];
- (void)Spawn {
[self createImage];
}
关于iphone - 没有 cocos2D 的 xcode iphone 粒子,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5706096/