Jump to content

Haxe Pixi - InteractionManager mouseMove is too damn high !


T0T0S
 Share

Recommended Posts

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

 

 

Link to comment
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..

Link to comment
Share on other sites

  • 2 weeks later...

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.

Link to comment
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...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...