Jump to content

[solved] Get object (group) properties on click.


willis
 Share

Recommended Posts

Hi

I'm new to phaser, i don't know how to get object properties on click, the result is 'undefined' instead of 8888. I use single object/sprite that not grouped and work fine.

create(){
		this.cards = this.add.group();

		var count = 1;
		for(var y=1; y<5; y++){
			
			var x_space = 70;
			var y_space = 100;
			var y_count = 0;
			for(var x=1; x<10; x++){
				if(count <= 36){
					this.cards.create(50+(x_space*x), 100+(y_space*y), 'card_'+count).setInteractive();
					this.cards.val = 8888;
				}

				if(x==10){
					y_count++;
				}
				count++;
			}
			
		}

		this.input.on('gameobjectdown', function(pointer, gameObject){
			console.log(gameObject.val);
		});
	}

 

Thanks

 

Solved http://labs.phaser.io/edit.html?src=src\input\game object\destroy sprite on down event.js

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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