xcode iphone particles without cocos2D

送分小仙女□ 提交于 2019-12-05 04:39:51

问题


is it possible to have particles without using cocos 2D. I know particle designer but we have to use it with cocos 2D. How can I make particles without cocos 2D ??


回答1:


You can do it by spawning an image and adding it to an array, which makes it extremly easy to animate the image or do whatever with it.

    - (void)createImage {

    UIImageView *Image = [[UIImageView alloc] initWithFrame:CGRectMake(arc4random() % 320, 480, 40, 40)];
    [Image setBackgroundColor:[UIColor blackColor]];
    [self.view addSubview:Image];
    [myArray addObject:Image];

}

That creates a black image wherever and adds it to an array.

Then, you can make a timer and spawn the image every second!

spawn = [NSTimer scheduledTimerWithTimeInterval:1.0/3 target:self selector:@selector(Spawn) userInfo:nil repeats:YES];


- (void)Spawn {

    [self createImage];

}



回答2:


You want to go right to 71Squared. He provides videos of creating a very cool particle engine without Cocos2d. Then, once you have your particle emitter workin, you can go ahead and create a simple class to store the particle sets if you want - I did this for my app.



来源:https://stackoverflow.com/questions/5706096/xcode-iphone-particles-without-cocos2d

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!