Sign in to follow this  
ranom

Mouse events - Stage.getMousePosition()

Recommended Posts

Trying to accomplish a very simple thing - get the x and y values of the current mouse coordinate.

 

I found this method defined here http://www.goodboydigital.com/pixijs/docs/classes/Stage.html#method_getMousePosition

However javascript console says: Uncaught TypeError: stage.getMousePosition is not a function

Using the latest pixi build (as of 14.5.2015). Are the docs outdated or am i doing something wrong?

 

Share this post


Link to post
Share on other sites

God I'm so stupid, it is "renderer.plugins.interaction" not "renderer.interaction" so sorry about that!!

 

if you was to make a drag or drop function, which one are u mostly likely to use?

function onMove (e){     var mouseData = renderer.plugins.interaction.mouse.global;}

or

function onMove (e){      var mouseData = e.data.getLocalPosition(stageContainer);}

Share this post


Link to post
Share on other sites

For drag specifically I don't think it matters because all that matters is the delta between the moves, not what the point is when you check. Whichever feels best to you is probably good, getLocalPosition does involve some matrix calculations so *maybe* you want to avoid that if you don't *need* to know the exact local position?

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...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.