Hi,
I have a script that creates entities and stores references to them in an array.
each time I create an entities I also attach a collisionstart event thus:
var newBullet = this.bulletprefab.clone();
this.app.root.addChild(newBullet);
this.bullets.push({entity: newBullet, timer : this.BULLET_LIFE, damage : 1});
newBullet.collision.on('collisionstart', this.oncollisionstart, this);
then I have a function which deletes the entity it collides with
Bullets.prototype.oncollisionstart = function(result) {
result.other.destroy();
};
But rather than delete the entity what I would like to do is pass through the damage value on the bullet through to a script on the entity but I am unsure of the syntax.
How can I pass the reference to the specific bullet or the index of the specific bullet through the collision event so that I can so something like:
result.other.script.myscript.method(bulletDamage);