vberegovoy

Click on emitter particles doesn't work

Recommended Posts

Hi, I am new on Phaser framework actually, but i am trying to find out.

I have an easy test game, where emitter moving from left to right, and drop particle, which is candy with 3 different state.

So i have to click on particle, and it has to change animation frame. When i click 3 time, particle have to disapear.

 

Here is my game code, but actually, i cannot make click event working. It looks like something wrong with my code, but i don't know where

<script>
		function getRandomInt(min, max)
		{
		  return Math.floor(Math.random() * (max - min + 1)) + min;
		}

		var game = new Phaser.Game('100%', '100%', Phaser.AUTO, '', { preload: preload, create: create, update: update });
		var emitter;
		
		function preload() {
			game.load.spritesheet('waffle', 'waffle_sprite.png', 150, 150, 3);
		}
		
		function create() {
//			game.physics.startSystem(Phaser.Physics.ARCADE);
			emitter = game.add.emitter(game, 100, 100, 20);
			
			emitter.inputEnableChildren = true;
			emitter.onChildInputDown.add(onDown, this);
			emitter.gravity = 0;
			emitter.minRotation = -100;
			emitter.maxRotation = 100;
			emitter.setYSpeed(150, 300);
			emitter.setXSpeed(50, 50);
			emitter.makeParticles('waffle', 0);
			
			setInterval(function(){
				emitter.x=getRandomInt((game.width * 0.1), (game.width - game.width * 0.1));
				emitter.start(true, 5000, null, 1);
			}, 1000)
		}
		function update() {
		}
		function onDown (sprite) {
			console.log(sprite);
		}
	</script>

Can you please help me fix click event on every child? Thank you!

I will continue my developing after fix this issue.

Share this post


Link to post
Share on other sites

Hello, It doesn't work for me neither. Any clues?

Here is my emitter configuration:


	var balloonsEmitter = game.add.emitter(0, 0, MAX_NUMBER_OF_BALLOONS);
	balloonsEmitter.enableBody = true;
	balloonsEmitter.inputEnableChildren = true;
	balloonsEmitter.onChildInputDown.add(function (balloon, pointer) {
		balloon.kill(); //delete particle
	});
	balloonsEmitter.gravity = 0;
	balloonsEmitter.makeParticles('balloonsPop', 0, 5);

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Recently Browsing   0 members

    No registered users viewing this page.