I do I get mouse position in relation to sprite?

0 favourites
  • 5 posts
From the Asset Store
Total customisation of the input! You can combine inputs from all peripherals. Make your game accessible for everyone!
  • So this is in regaurds to another post I have but its not going in the direction I need it to go AND I'm attempting to apply a solution that I do not understand how it works.

    Instead I will ask this.

    I am using the tile-movement behavior. I like the way it works, and it will work for the project that I am attempting to make.

    I remapped the arrow keys to the wsad keys.

    I am now attempting to do the very same thing that the arrow/WSAD keys do but with a mouse click.

    I think that I need to first get the mouse position in relation to the sprite, OR the mouse position in relation to the image point on the sprite.

    After that I need to calculate or store that position.

    If that position is 0 to 90 degrees in relation to the sprite when clicked, then I want simulate the tile-movement behavior to go up. 91 to 180, move to the right..so on and so forth.

    So...how do I find the mouse position so I can start working this out?

    I would assume that I would have to use a local or global varible to first store the mouse position, but I'm not sure how to actually get the position.

    This is what I have so far.:

    Where do I go from here, and am I close?

  • So...how do I find the mouse position so I can start working this out?

    Have you tried the manual?

    construct.net/en/make-games/manuals/construct-3/plugin-reference/mouse

    You can save Mouse.x and Mouse.y when an object is clicked in a pair of variables (global/local or instance). Then on every tick compare the distance and angle between the saved and new position of mouse cursor. Use distance() and angle() expressions.

    Say, if the distance is >50px and the angle is between 150 and 210 degrees, you can assume that this is a "left swipe".

    Another option is to use the Touch plugin instead. It already has Touch.SpeedAt and Touch.AngleAt expressions which can be used to easily detect swipes. And it's compatible with mouse.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The following file has a simple example that may help you understand the building blocks of what you are trying to do.

    drive.google.com/file/d/1jU1yCX-pjCu-le8eKszBk6FKRdu6TUr3/view

  • Thank you I will start reading tonight.

  • Figured it out with your help. Thank you.

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