Object animation - c4framework

I am currently working on a project that I built using the alpha C4 framework.

I am trying to start the animation as soon as the application starts without using any interaction to achieve this (i.e. touchhesBegan) ...

But, unfortunately, I cannot understand this.

+3
source share
1 answer

In C4, the way to do this is to use the following method:

-(void)performSelector:withObject:afterDelay:

And for the current version of C4, the best way to use this is:

#import "C4WorkSpace.h"

@interface C4WorkSpace ()
-(void)methodToRunImmediately;
@end

@implementation C4WorkSpace {
    C4Shape *circle;
}

-(void)setup {
    circle = [C4Shape ellipse:CGRectMake(100, 100, 100, 100)];
    [self.canvas addShape:circle];
    [self performSelector:@selector(methodToRunImmediately) withObject:nil afterDelay:0.1];
}

-(void)methodToRunImmediately {
    circle.animationDuration = 1.0f;
    circle.animationOptions = AUTOREVERSE | REPEAT;
    circle.center = CGPointMake(384, 512);
}
@end

This code will start your animations after the 1 / 10th second of the delay ... which will look immediately.


, , , . :

-(void)runMethod:afterDelay:

, C4 :

[self performSelector:@selector(methodToRunImmediately) 
           withObject:nil 
           afterDelay:0.1];

... :

[self runMethod:@"methodToRunImmediately" afterDelay:0.1];
+2

All Articles