How do I set animation frame based on mouse click and drag?

0 favourites
  • 3 posts
From the Asset Store
Selection frame like in RTS games, works both on mobile and desktop devices.
  • I have a sprite that is the image of a selector knob:

    I also have a global variable called dragAndDropTest that will be renamed selectorKnobValue.

    I am looking for a way to set the value of dragAndDropTest when clicking and dragging the mouse (not actually dragging because the sprite/knob wont move at all).

    Moving the mouse left, dragAndDropTest is set to dragAndDropTest - 1.

    Moving the mouse right, dragAndDropTest is set to dragAndDropTest + 1.

    There is another condition checking that the value does not go below 0 and neither increases over the number of the last animation frame.

    The X value of 795 represent the center of the button.

    This partially works = When I click to the right of knob center, dragAndDropTest increases by one. Clicking to the left of knob center most of the time work as well, but it is not as consistent. Any idea why?

    Wanted additional functionality: I want the user to be able to click and drag the knob, as this is expected functionality/behaviour when interacting with elements like this on a computer screen. Click knob, and drag left should decrease dragAndDropTest -1, while Click knob, drag right should increase dragAndDropTest +1.

    Does anybody have suggestion on how to implement this mouse click+drag behaviour?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thank you so much!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)