Search code examples
iphonexcodeanimationcocos2d-iphoneparticles

xcode iphone particles without cocos2D


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 ??


Solution

  • 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];
    
    }