本文整理汇总了C#中ParticleEffect.Initialize方法的典型用法代码示例。如果您正苦于以下问题:C# ParticleEffect.Initialize方法的具体用法?C# ParticleEffect.Initialize怎么用?C# ParticleEffect.Initialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParticleEffect
的用法示例。
在下文中一共展示了ParticleEffect.Initialize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParticleSystem
public ParticleSystem(ParticleSettings settings, Effect effect)
{
if (settings == null) throw new ArgumentNullException("settings");
if (effect == null) throw new ArgumentNullException("effect");
if (settings.Texture == null) throw new ArgumentException("Texture is null.");
Enabled = true;
this.settings = settings;
//----------------------------------------------------------------
// システム名
Name = settings.Name;
//----------------------------------------------------------------
// エフェクト
particleEffect = new ParticleEffect(effect);
particleEffect.Initialize(settings, settings.Texture);
graphicsDevice = particleEffect.GraphicsDevice;
//----------------------------------------------------------------
// パーティクル
particles = new ParticleVertex[settings.MaxParticles * 4];
for (int i = 0; i < settings.MaxParticles; i++)
{
particles[i * 4 + 0].Corner = new Short2(-1, -1);
particles[i * 4 + 1].Corner = new Short2(1, -1);
particles[i * 4 + 2].Corner = new Short2(1, 1);
particles[i * 4 + 3].Corner = new Short2(-1, 1);
}
//----------------------------------------------------------------
// 頂点バッファ
vertexBuffer = new DynamicVertexBuffer(
graphicsDevice, ParticleVertex.VertexDeclaration, settings.MaxParticles * 4, BufferUsage.WriteOnly);
//----------------------------------------------------------------
// インデックス バッファ
var indices = new ushort[settings.MaxParticles * 6];
for (int i = 0; i < settings.MaxParticles; i++)
{
indices[i * 6 + 0] = (ushort) (i * 4 + 0);
indices[i * 6 + 1] = (ushort) (i * 4 + 1);
indices[i * 6 + 2] = (ushort) (i * 4 + 2);
indices[i * 6 + 3] = (ushort) (i * 4 + 0);
indices[i * 6 + 4] = (ushort) (i * 4 + 2);
indices[i * 6 + 5] = (ushort) (i * 4 + 3);
}
indexBuffer = new IndexBuffer(graphicsDevice, typeof(ushort), indices.Length, BufferUsage.WriteOnly);
indexBuffer.SetData(indices);
}