Sign in to follow this  

Haxe Pixi - InteractionManager mouseMove is too damn high !

Recommended Posts

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 :)



Share this post

Link to post
Share on other sites

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..

Share this post

Link to post
Share on other sites

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) 
	oldMoveFunction (event);

renderer.plugins.interaction.onMouseMove = untyped newMoveFunction.bind(renderer.plugins.interaction);


Just remember to reset to 0 "mouseEventCallThisFrame" at every game loop.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.