T0T0S Posted December 22, 2015 Share Posted December 22, 2015 Hello, I've got a problem that is starting to impact the performance of my game and I found through profiling that the MouseMove & ProcessMouseMove, are binded to the window "mousemove" event. They do fire correctly, but I simply need them to fire once per frame. ( They fire 5 - 10 times per frame which is normal ) Is there a way to do this in pixi with interactionFrequency, or do I need to do some hack ? Thanks in advance Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted December 23, 2015 Share Posted December 23, 2015 Ok, so there are two things: 1) it fires on real move move2) it fires in onUpdate() timer Yes, its too damn high, I think I think you have to patch InteractionManager yourself before we fix that thing, its not that hard. You will implement all this code anyway Quote Link to comment Share on other sites More sharing options...
T0T0S Posted December 23, 2015 Author Share Posted December 23, 2015 Alright, Thanks Ivan, I'll find a work around, Still, it would be nice to have it already built-in Pixi. Quote Link to comment Share on other sites More sharing options...
GBear Posted December 23, 2015 Share Posted December 23, 2015 you need to check sturcture of containers.. pixi is always check all containers.. so if you use containers not having some plan to struct. you can be encountered.... if you reduce containers or if you use interactveChildren parameter.. you can optimize more.. Quote Link to comment Share on other sites More sharing options...
T0T0S Posted January 4, 2016 Author Share Posted January 4, 2016 I've made a work around that works well var mouseMaxCallPerFrame = 1; var mouseEventCallThisFrame = 0; var renderer = Pixi.Detector.autoDetectRenderer(1600, 900, {}); var oldMoveFunction = renderer.plugins.interaction.onMouseMove; var newMoveFunction:Dynamic = function(event):Void { if (mouseEventCallThisFrame >= mouseMaxCallPerFrame) return; ++mouseEventCallThisFrame; oldMoveFunction (event); } renderer.plugins.interaction.onMouseMove = untyped newMoveFunction.bind(renderer.plugins.interaction); renderer.plugins.interaction.setTargetElement(renderer.view); Just remember to reset to 0 "mouseEventCallThisFrame" at every game loop. 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.