Jump to content

Question about mousemove


aqualonix
 Share

Recommended Posts

Hi! Sorry for the simple question!

With this code I have an animation that character's eyes are tracking to mouse from the start and another unique animation when I'm clicking on the character. But I want to change it for "click and hold" so eyes are tracking mouse while user is holding his left button and eyes stop following mouse after button release. And I want to save option for unique animation with single click. Sorry, maybe its a stupid question, but I'm really stuck, I checked http://pixijs.download/dev/docs/PIXI.interaction.InteractionManager.html, but another events aren't working. 

live2dSprite.on('click', (evt) => {
  const point = evt.data.global;
  if (live2dSprite.hitTest('body', point.x, point.y)) {
    live2dSprite.startRandomMotionOnce('tap_body');
  }
  
});

live2dSprite.on('mousemove', (evt) => {
  const point = evt.data.global;
  live2dSprite.setViewPoint(point.x, point.y);
});

 

Link to comment
Share on other sites

7 minutes ago, ivan.popelyshev said:

I dont know whether live2d actually has containsPoint or any other function that allows pixi to detect whether the object was clcked. Which runtime do you use?

live2dSprite.hitTest can detect it but I want allow to click and hold anywhere in the renderer (even on the character) for eyes to start following the mouse and click and release only on the character's body to start unique animation.

Link to comment
Share on other sites

7 minutes ago, ivan.popelyshev said:

Then you have to be familiar with pixi interaction to hook live2d in it properly. You can ask in official live2d js repo about it. and if they dont have solution for it, we'll have to help them make better plugin.

I just can't understand how to change "mousemove" to "click and pressed". Its not about live2d, I'm just stuck on it right now. Maybe I can use if, but how can I stop mousemove after first activation?

Link to comment
Share on other sites

4 minutes ago, ivan.popelyshev said:

pointerdown, pointermove, pointerup

did you do that for DOM or canvas without pixi or in other platform that is not HTML5? If not, I'm afraid that's more coding question then. Look at dragging example http://pixijs.io/examples/#/demos/dragging.js

canvas, I was thinking how to do it only with one event

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