Cocos2d API 解析之IntervalTest

ParticleSystem* sun = [ParticleSun node]
ParticleSun:是粒子特效中的太阳效果
ParticleSnow:下雪效果

该例子主要展示的是定时(Interval)调用的例子:
    label1 = [Label labelWithString:@"0" fontName:@"Courier" fontSize:32];
    [self schedule: @selector(step1:) interval: 0.5f]; //每隔0.5秒执行一次

-(void) step1: (ccTime) delta
{
//    time1 +=delta;  //时间累加
    time1 +=1;
    [label1 setString: [NSString stringWithFormat:@"%2.1f", time1] ];
}


暂停处理:
    // pause button
    MenuItem *item1 = [MenuItemFont itemFromString: @"Pause" target:self selector:@selector(pause:)];
    Menu *menu = [Menu menuWithItems: item1, nil];
    menu.position = ccp(480/2, 270);

    [self addChild: menu];


-(void) pause: (id) sender
{
    [[Director sharedDirector] pause];   //实现暂停效果
   
    // Dialog   //alert控件的用法
    UIAlertView* dialog = [[UIAlertView alloc] init];
    [dialog setDelegate:self];
    [dialog setTitle:@"Game Paused"];
    [dialog setMessage:@"Game paused"];
    [dialog addButtonWithTitle:@"Resume"];
    [dialog show];   
    [dialog release];
}

你可能感兴趣的:(sun)