willis

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

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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.