Sign in to follow this  
Griva

Pixi hitArea for whole stage

Recommended Posts

I have on stage special "workspace" pixi container -  I use it to allow user to draw on it.  It works perfect if I set hitArea dimensions to renderer width and height but the problem is that user can move this layer or zoom in/out.
I think result is obvious, after move/zoom it is not possible to draw on canvas because hitArea "run" out from the screen or it is too small.

My question is what is the best actual solution for this (pixi v4)?

I was thinking about setting Infinite hitArea but this is not possible. I could set hitArea Rectangle to be like 999999px so it should not be possible to go out of drawing area but is it ok? Can setting very big hitArea slow down interaction manager?
Also another option was to replace hitArea (make it bigger) after move/zoom but this is proably not the best idea. Is there any elegant solution to cover this case easly?

Share this post


Link to post
Share on other sites

You could also consider adding your events at the renderer level, and do some maths to translate to your container.

ie. 

let location = new PIXI.Point();

renderer.plugins.interaction.on( 'pointerdown', ( event ) => {
  container.worldTransform.applyInverse( event.data.global, location );
}

 

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.