Pau

Coordinates relative to parent object

Recommended Posts

Hello,

I would like to create a interactive zone which is relative to an existing sprite.

For example, this code is working:

var marcoObjs = this.add.sprite(x, y, 'marcoObjs');
var puerta1 = this.add.zone(50, 50, 100, 100)
puerta1.setInteractive();
this.add.graphics().lineStyle(2, 0xff0000).strokeRectShape(puerta1);

But i want the puerta1 object to be relative positioned to marcoObjs object. So if marcoObjs x,y coordinates change, puerta1 coordinates must change too. I tried this way, but is not working:

var marcoObjs = this.add.sprite(x, y, 'marcoObjs');
var puerta1 = marcoObjs.add.zone(50, 50, 100, 100)
puerta1.setInteractive();
this.add.graphics().lineStyle(2, 0xff0000).strokeRectShape(puerta1);

Any Ideas?

Thank you in advance.

 

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.