<cocos2D>画会动的直线

//MyLayer.h
@interface MyLayer : ccLayer {
    CGPoint curpos;
    CGPoint originpos;
}

@end

//MyLayer.m

@implementation MyLayer
-(id)init{
    self = [super init];
    if(nil != self){
        curpos.x = 10.0f;
        curpos.y = 10.0f;
        originpos.x = 10.0f;
        originpos.y = 10.0f;
        
        [self schedule: @selector(tick:) interval:0.1];
    }
    return self;
}

-(void)tick:(ccTime)dt{
    curpos.y = curpos.y +1;
}

-(void)draw{
    glColor4f(0.8, 1.0, 0.76, 1.0);  
    glLineWidth(2.0f);
    ccDrawLine(originpos,curpos);
}

@end

posted @ 2012-11-17 15:30  白条围巾  阅读(193)  评论(0编辑  收藏  举报