[cocos2d html5] particles

http://www.cocos2d-x.org/wiki/Particles?project_id=cocos2d-x

Point vs Quad
よくわかりませんが、Quadのほうが拡張されているようです。

v2.2で
cc.ParticleSystemQuad.create(); -> cc.ParticleSystem.create();
となっているのでもうQuadで良いような雰囲気ですね

とりあえず作ってみる。
Gravityモードというのは、中心から拡散されるような感じになるそうで

ParticleFireはGravityモードだそうで
var effectLayer = cc.Layer.create();
this.addChild(effectLayer);
this._emitter = cc.ParticleFire.create();
this._emitter.setTexture(cc.TextureCache.getInstance().addImage("fire.png"));
effectLayer.addChild(this._emitter);

こんな感じで出来ました。

Radiusモードのサンプルをそのまま貼付けただけですが、くるくる回りました。
this._emitter = cc.ParticleSystem.createWithTotalParticles(100);
this._emitter.setTexture(cc.TextureCache.getInstance().addImage("fire.png"));
// duration
this._emitter.setDuration(5);
// this._emitter.setDuration(cc.PARTICLE_DURATION_INFINITY);
// radius mode
this._emitter.setEmitterMode(cc.PARTICLE_MODE_RADIUS);
// radius mode: start and end radius in pixels
this._emitter.setStartRadius(0);
this._emitter.setStartRadiusVar(0);
this._emitter.setEndRadius(160);
this._emitter.setEndRadiusVar(0);
effectLayer.addChild(this._emitter);
// radius mode: degrees per second
this._emitter.setRotatePerSecond(180);
this._emitter.setRotatePerSecondVar(0); // angle
this._emitter.setAngle(90);
this._emitter.setAngleVar(0);
// emitter position
var size = cc.Director.getInstance().getWinSize();
this._emitter.setPosition(size.width / 2, size.height / 2);
this._emitter.setPosVar(cc.p(0, 0));
// life of particles
this._emitter.setLife(5);
this._emitter.setLifeVar(0);
// spin of particles
this._emitter.setStartSpin(0);
this._emitter.setStartSpinVar(0);
this._emitter.setEndSpin(0);
this._emitter.setEndSpinVar(0);

とりあえず、サンプルを見ながら適当に作れるようです。

this._emitter = cc.ParticleRain.create();
this._emitter.setTexture(cc.TextureCache.getInstance().addImage("fire.png"));
this._emitter.setSpeed(0.1);
this._emitter.setRadialAccel(10);
effectLayer.addChild(this._emitter);

絵とデフォルトの設定を適当に変えるだけでもかなり変わるようです。

技の効果はこれで十分そうです。

This entry was posted on 木曜日, 11月 7th, 2013 at 11:48 AM and is filed under cocos2d. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

Unityによるゲームを公開しております iOS/Android
https://itunes.apple.com/jp/app/lost-knight-3d-action/id900917032
https://play.google.com/store/apps/details?id=com.groundroad.runknight

各種開発支援・機能開発等小さいお仕事などもお請けしております。
unity開発支援, PHPシステム開発, javascript/html5 フロント開発, titanium mobileアプリ開発
お気軽にお問い合わせください
大崎・五反田近郊での対面でのお打ち合わせはいつでも可能です。