Jump to content

Coordinates of a sprite in pixi and in the browser's dom


Recommended Posts

I am using pixi version 4.8.5 and I am trying to access the coordinates of a Sprite when I click on it through its event like this:


I have also tried like this:


I want these coordinates to show just above that sprite in the browser an element that I have hidden in my html, but the coordinates that it is giving me from the event do not appear at the same point where I click.

Does Pixi have any better way to indicate the coordinates of the browser's DOM and not the container where the sprite is? I think that is my problem.

I have also tried:


In order to obtain the coordinates but he does not give them to me precisely for the DOM.


Link to comment
Share on other sites

from you event scope just use

this.toLocal(e.data.global); // or mySprite.toLocal(e.data.global)

Suppose this is the scope of your sprite to your event, example of use case for anime element from your mouse to a sprite as children.

            pointerup(e) {
                const from = this.toLocal(e.data.global);
                TweenLite.fromTo(elementFromMouseToThisSprite, 0.3  ,{x:from.x, y:from.y}, { x:0, y:0});


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.

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.


  • Recently Browsing   0 members

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