Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by DaveVoyles

Something I noticed recently:

In my 2d side scrolling shooter, when my ship's bullets hit an enemy, the particles are being spawned in the top-left corner of each object. Why is that happening?

I have not adjusted the pivot, so as far as I know, they should be spawning from the center of the object, right?

1 decade ago by Joncom

The origin is always the top-left. It's not like Flash or Box2D where the origin is the center. If you want to spawn something at the very center of something else:

// Spawn a particle centered over the player.
var x = player.pos.x + player.size.x/2 - EntityParticle.prototype.size.x/2;
var y = player.pos.y + player.size.y/2 - EntityParticle.prototype.size.y/2;
ig.game.spawnEntity(EntityParticle, x, y);

1 decade ago by DaveVoyles

Much appreciated, that explains it.

It's probably always been that way, and for some reason I'm just noticing it now.

Thank you!
Page 1 of 1
« first « previous next › last »