Jump to content

Kill sprite after rotating for an amount of time.


AGoodUsername
 Share

Recommended Posts

So I have a line that constantly rotates, and it is in a group:

		this.lines = game.add.group();
		this.lines.enableBody = true;
		this.lines.physicsBodyType = Phaser.Physics.ARCADE;
		this.lines.createMultiple(50, 'line');
		this.lines.setAll('checkWorldBounds', true);
		this.lines.setAll('outOfBoundsKill', true);
		this.timer = game.time.events.loop(1000, this.disco, this); 

and my ray-creator function:

		r = Math.random();		
		if(r < 0.5){
			this.ray = this.lines.getFirstDead();
			
			this.ray.reset(101, 20);
			
			this.ray.body.angle = -90;
			this.ray.body.angularVelocity = 100;
		}

 

In the update function, this is what I am doing to kill the ray:

if(this.ray.angle >=90){
    this.ray.kill();
}

The console error is error: this.ray is not defined. So my question is, how would I fix this so it would kill the ray once its angle is over 90 degrees?

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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