Jump to content

Particle collision


RollinSafary
 Share

Recommended Posts

i'm trying to change collision option after emitter had started but i can't

create () {
    // --------------------------------CONFIG--------------------------------
    this.config = {
      'followCursor': false,
      'mouseClick': false,
      'gravityX': 0,
      'gravityY': 0,
      'positionX': 960,
      'positionY': 540,
      'maxParticles': 50,
      'particleKey': 'particle',
      'frames': 1,
      'quantity': 5000,
      'collide': false,
      'collideWorldBounds': false,
      'scaleToX': 1,
      'scaleToY': 1,
      'scaleRate': 0,
      'scaleEase': Phaser.Easing.Linear.None,
      'scaleYoyo': false,
      'alphaMin': 1,
      'alphaMax': 0,
      'alphaRate': 0,
      'alphaEase': Phaser.Easing.Linear.None,
      'alphaYoyo': false,
      'rotationMin': 0,
      'rotationMax': 0,
      'bounceX': 0,
      'bounceY': 0,
      'angularDrag': 0,
      'particleMinSpeedX': -300,
      'particleMinSpeedY': -300,
      'particleMaxSpeedX': 300,
      'particleMaxSpeedY': 300,
      'emitterSpeedX': 200,
      'emitterSpeedY': -200,
      'lifespan': 500,
      'particleFrequency': 250,
      'particleQuantity': 500
    }
    // --------------------------------EMITTER--------------------------------
    this.emitter = this.game.add.emitter(this.config.positionX, this.config.positionY, this.config.maxParticles)
    this.makeParticles()
    this.emitter.minParticleSpeed.setTo(this.config.particleMinSpeedX, this.config.particleMinSpeedY)
    this.emitter.maxParticleSpeed.setTo(this.config.particleMaxSpeedX, this.config.particleMaxSpeedY)
    this.emitter.gravity.x = this.config.gravityX
    this.emitter.gravity.y = this.config.gravityY
    this.emitter.setScale(this.config.scaleFromX, this.config.scaleToX, this.config.scaleFromY, this.config.scaleToY,
      this.config.scaleRate, this.config.scaleEase, this.config.scaleYoyo)
    this.emitter.setAlpha(this.config.alphaMin, this.config.alphaMax, this.config.alphaRate,
      this.config.alphaEase, this.config.alphaYoyo)
    this.emitter.angularDrag = this.config.angularDrag
    this.emitter.setRotation(this.config.rotationMin, this.config.rotationMax)
    this.emitter.bounce.setTo(this.config.bounceX, this.config.bounceY)
    this.emitter.setXSpeed(this.config.emitterSpeedX)
    this.emitter.setYSpeed(this.config.emitterSpeedY)
    this.startEmitter()
// here I want to change both collision options from false to true, and to make it work with new collision options
  }

  startEmitter () {
    this.emitter.start(false, this.config.lifespan, this.config.particleFrequency,
      this.config.particleQuantity, false)
  }
  makeParticles () {
    this.game.add.emitter(this.config.positionX, this.config.positionY, this.config.maxParticles)
    this.emitter.makeParticles(this.config.particleKey, this.config.frames, this.config.quantity,
      this.config.collide, this.config.collideWorldBounds)
  }

Can anybody help me in this?

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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