! Choose language
選擇你的語言
close  
 語言 

Announcement

  • 李小鑫
    毕业了四年,我还是我,一点没有变。

Blog entry

  • cocos2d播放雪花

    Wednesday, Jan 4, 2012 12:25PM / Standard Entry / Members only

    -(void)playEffectSnow

    {

    //使用自带下雪粒子

    CCParticleSnow *particle = [CCParticleSnow node];

    //自定义雪花图片

    particle.texture = [[CCTextureCache sharedTextureCache] addImage:@"effect_snow.png"];

    //粒子总数

    particle.totalParticles = 400;

    //下雪时间 秒

    particle.duration = 3;

    //雪花开始大小

    particle.startSize = 40;

    //雪花大小浮动

    particle.startSizeVar=20;

    //雪花结束大小

    //particle.endSize = 50;

    //particle.endSizeVar = 30;

    //初始速度

    particle.speed = 20;

    particle.speedVar = 15;

    //下降速度 y负数表示下落 x负数表示向西吹

    particle.gravity = ccp(-20, -70);

    //每个雪花生命时间

    particle.life = 4.0f;

    particle.lifeVar = 2.0f;

    //particle.position = ccp(240, 320);

    //释放雪花速度

    particle.emissionRate = particle.totalParticles/particle.life;

    //动画完成后自动从上层layer中移除粒子

    particle.autoRemoveOnFinish = YES;

    //释放粒子位置

    particle.position = (CGPoint) {

    [[CCDirector sharedDirector] winSize].width / 2,

    [[CCDirector sharedDirector] winSize].height + 10

    };

    particle.posVar = ccp( [[CCDirector sharedDirector] winSize].width / 2+50, 0 );

    //添加到layer中

    [gly addChild:particle z:1000];

    }

      24 views Share      

Entry comments

Blog entries More entries >

Stats

  • 80后,双眼皮单身帅哥一个。...

    More

  • Age: 28
  • Gender: Male
  • Total visits: 8,962

RSS feed

    Share 分享到:


Shout box

Please first sign in or sign up for FREE to post to the Shout Box.

Archived shouts

Join the alivenotdead.com community uniting musicians, filmmakers, and other artists with their fans