开发者

Why isn't CADisplayLink working in this case?

I want to use CADisplayLink instead of NSTimer for an animation of a ball which is just moving, but with CADisplayLink it doesn't work. What could be the problem in the following code?

#import "UntitledViewController.h"


@i开发者_JAVA技巧mplementation UntitledViewController
@synthesize maBalle;


-(void) update:(CADisplayLink*)displayLink {
}

-(void)topHorloge {
    maBalle.center =CGPointMake(maBalle.center.x+coordonnees.x,maBalle.center.y+coordonnees.y);
    if((maBalle.center.x)-20 <0 || (maBalle.center.x)+20 >320)
        coordonnees.x=-coordonnees.x;
    if((maBalle.center.y)-20 <0 || (maBalle.center.y)+20 >460)
        coordonnees.y=-coordonnees.y;
}

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
    displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(renderAndUpdate)];
    [displayLink setFrameInterval:2];
    [displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];


}


Where is your renderAndUpdate handler? (which you specified as your displaylink callback)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜