pongstylin Posted June 4, 2015 Share Posted June 4, 2015 TL;DR: Why does the interaction manager add itself to the ticker? Events seem to work fine without it - even mouse over/out. First of all, this is some great work. I haven't looked at my pixi-based project since January, and now that I'm resuming work I'm updating to PIXI v3 and am liking what I see in the code. What is especially awesome is disconnecting the event loop from the render loop using this fancy ticker object. This is due to my particular use case where I am not running animations continuously. Animations are triggered by user interaction and may be stopped by the animation completing or by another user interaction. So as long as nothing is happening visually, I want nothing to happen behind the scenes either. So in my obsessed quest for high performance and preserved battery life, in PIXI v2 I triggered a render event every time I detected a mouse move on the canvas. If I didn't do this, then mouse over/out events did not trigger correctly. Otherwise, I only rendered as I changed things and called it a day. The only thing that sucked was using slow browsers (*ahem* Firefox) on poor GPUs. As my animations ran at a modest 12 FPS, I noticed a performance hit as I moved my cursor around, triggering rapid, unthrottled, rendering - Yuck! I never did get around to doing something about that... So now I'm in the beautiful new world of PIXI v3. I see a fancy ticker object and the interaction manager adding itself to it and throttling itself. Theoretically, I could just turn off the ticker and call the interaction manager update myself in my mouse move event handler - taking advantage of doing less work and throttling. But I might want to make use of the ticker. So I commented out the line where the interaction manager added itself to the ticker. But before I did the whole mouse move business, I did a little testing without it entirely and was surprised at what I found. Without the ticker running and the interaction manager update ever getting called, mouse over/out and all other mouse and touch events seem to work just fine! Amazing. So why does it add itself to the ticker? What am I missing? Some information I gleaned in method call chains...update() => processMouseOverOut()onMouseMove() => processMouseMove() => processMouseOverOut()onMouseOut() => processMouseOverOut() All roads lead to processMouseOverOut(), so the update() seems redundant... Quote Link to comment Share on other sites More sharing options...
xerver Posted June 9, 2015 Share Posted June 9, 2015 The interaction manager needs to do checks because the scene moves even when mouse events aren't firing. Consider the example of a sprite moving around on the screen and your mouse not moving at all. When the sprite goes under your mouse there should be an interaction event, but no mouse event has fired so how do we know it happened? So we cache state on mouse events and do checks on an interval. Quote Link to comment Share on other sites More sharing options...
pongstylin Posted June 10, 2015 Author Share Posted June 10, 2015 Hah! Sure enough. I tested my app to see if my cursor would change to a pointer after an animation completed. It did when I had the InteractionManager plugged into the ticker. It didn't when it wasn't until I moved the mouse one pixel. So let's say I'm fine with the pointer not showing up until I move the mouse. Is that the only reason to run the manager through the ticker? Quote Link to comment Share on other sites More sharing options...
xerver Posted June 10, 2015 Share Posted June 10, 2015 IIRC, yes that is the only reason 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.