neonwarge04 Posted September 10, 2015 Share Posted September 10, 2015 Hi,I am trying this code:this.mSprite.on('mousemove' , (function(mouseData){var mousePos = mouseData.data.getLocalPosition(this.mStage);console.log("Mouse position : " + mousePos.x + " , " + mousePos.y);}).bind(this));Unfortunately, the mouse is still being detect even though its outside of the game view area. I got this information on this site though its a bit outdated: http://www.goodboydigital.com/pixi-js-now-even-better-at-being-interactive/ How can I get mouse position relative on the view?Thank you! Quote Link to comment Share on other sites More sharing options...
coolblue Posted September 10, 2015 Share Posted September 10, 2015 Yes, that's interesting: I can confirm the same problem... all the other events work great but that one is not what you would expect. My observation is that, any mouse move, anywhere in the document calls back on every registered listener and by anywhere I include outside of the renderer view element , so, something strange there... (EDIT: this is already registered as a bug: #1837 and #1884. #2071 is also relevant ) But, you don't actually need that one, you need mouseover....on('mouseover', f) ...works great. Perhaps that's what you want? neonwarge04 1 Quote Link to comment Share on other sites More sharing options...
neonwarge04 Posted September 10, 2015 Author Share Posted September 10, 2015 I will try the mouseover and apply it to Container this morning and see if it works as I was trying this on the sprite itself! I have yet to try if this works on container. Thanks for the issue numbers. I am not aware this is a bug. I thought I just missed something. Quote Link to comment Share on other sites More sharing options...
coolblue Posted September 11, 2015 Share Posted September 11, 2015 mouseover will work on the sprites also, you don't need to apply it to the container.But... their container does need to be the last object rendered, I am about to post another question to verify that this is necessary but it seems like it is. Quote Link to comment Share on other sites More sharing options...
neonwarge04 Posted September 16, 2015 Author Share Posted September 16, 2015 How are we suppose to get around this? Well I can live on just simply getting the X for as long as the canvas stays at the most top-left, if not I have to account for it. I am just checking if is possible though... Quote Link to comment Share on other sites More sharing options...
coolblue Posted September 16, 2015 Share Posted September 16, 2015 Well, you have two choices that I can think of... Cherry-pick the code and make your own interaction manager/renderer patch (until the rewrite is done) Keep the objects you want to interact with in the same container as everything in front of it. You can add other display objects to the container after the active objects, you just need to tag the active ones - or partition your container.children array - if you need to treat them separately in other parts of your code. The limitation is in the renderer, not the container... EDIT: actually there is a third and better option (sorry, I'm learning as I go...), you can nest containers: you can use nested containers to group elements to partition your active layer. Quote Link to comment Share on other sites More sharing options...
neonwarge04 Posted September 17, 2015 Author Share Posted September 17, 2015 I see, I think I just have to write a work around to this. Thanks! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.