Jump to content

Spawn an image when clicking a button


JavaNerd
 Share

Recommended Posts

I keep getting this.add is undefined.

		// Building button
		ui1.on('pointerdown', function ()
		{
			var window = this.add.image(0, 0, 'window').setOrigin(0);
			window.setScrollFactor(0);
			window.setDepth(1002);
			window.x = 20;
			window.y = 20;
		});

I'm trying to spawn an image into the game when the user clicks on the button.

Link to comment
Share on other sites

14 hours ago, PsichiX said:

check docs about .on function - if it accepts third parameter as context, pass your proper context instance - if not, bind this anon function with context:

ui1.on('name', function(){}, someParent);

or:

ui1.on('name', (function(){}).bind(someParent));

Once again, thank you!

Link to comment
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...
 Share

  • Recently Browsing   0 members

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