Jump to content

Order that collided objects are passed to callback


michaelcalkins
 Share

Recommended Posts

I had this weird issue where originally I passed `this.platforms` first then `this.enemyBullets` into overlap or collide and the `collideCallback` would always pass the bullet as the first param regardless of the order I called with overlap or collide.

this.enemyBullets is an array.

this.platforms is a group.

Idk if this is a bug or not but wondering if I was using it wrong.

    this.physics.arcade.overlap(this.enemyBullets, this.platforms, function(bullet) {
        bullet.kill()

        let ricochet = this.add.sprite(bullet.x, bullet.y - 15, 'ricochet')
        ricochet.scale.setTo(.17)
        ricochet.animations.add('collision', [0,1,2,3,4,5], 45, false, true)
        ricochet.animations.play('collision')
        ricochet.animations.currentAnim.killOnComplete = true

        emitBulletRemoved.call(this, {
            roomId: this.roomId,
            bulletId: bullet.bulletId
        })
    }, null, this)

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...