Skip to content

Instantly share code, notes, and snippets.

@zilluss
Created April 22, 2015 09:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zilluss/219a4c32feb59c3a0222 to your computer and use it in GitHub Desktop.
Save zilluss/219a4c32feb59c3a0222 to your computer and use it in GitHub Desktop.
Test case for b2ParticleSystem.GetParticleCount() and b2ParticleSystem.GetPositionBuffer()
function TestCreateParticle() {
var psd = new b2ParticleSystemDef();
var particleSystem= world.CreateParticleSystem(psd);
var expectedParticleCount = 50;
for(var i = 0; i < expectedParticleCount; i++) {
var pd = new b2ParticleDef();
pd.position = new b2Vec2(i, 0);
particleSystem.CreateParticle(pd);
}
var assertParticleCount = "Expected particle count: " + expectedParticleCount + " actual: " + particleSystem.GetParticleCount();
var assertPositionBuffer = "Expected position buffer size: " + (expectedParticleCount * 2) + " actual: " + particleSystem.GetPositionBuffer().length;
console.log(assertParticleCount);
console.log(assertPositionBuffer);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment