Reproduce mouse movement

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!
  • HI,

    I am trying to make a sprite reproduce the movement of my mouse when i have my left mouse button down. It "works" but, i don't understand why, the sprite move faster than the mouse. So this is my capx :

    https://dl.dropboxusercontent.com/u/23569593/FORUM%20C2%20-%20Panda/Panda%20Party%20Night.capx

    I'm think it's a problem with the math but i don't know where... :s

    Help ?

  • yea i took a stab at it, but my math skills suck.. but i made this really rough and dirty almost right capx you can try out.. it isn't properly setup, the coordinates are out of whack but notice that it does track with the mouse movement without flying off the screen https://www.dropbox.com/s/noiijo4afpbbf ... mouse.capx

    i think there just needs to be some better math to establish where X and Y of the mouse and the X and Y of the sprite are to insure they move in unison.

  • not sure what you're trying to do, if you just want the sprite to follow the mouse

    on left mouse down,

    set sprite position to x = mouse.x and y = mouse.y

    using arrays would only be needed if you want to record the mouse movement

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Part12Studios : Thanks. The movement works but i don't understand how to not move the sprite when you click on the left button. It's come from this part but i don't find a way to skip that part.

    "MouseDown = 1

    Trigger once

    ->Set MouseX to mouse.X-sprite.X

    ->Set MouseY to mouse.Y-sprite.Y"

    I want that the sprite keep it's initial position when I left clicked.

    Vtrix : I don't want the sprite to follow the mouse, I want it to reproduce the mouse movement. I want that when i clicked on the left mouse button and, for example, i go to the left with my mouse the sprite go to the left to. But i don't want the sprite to teleport to the mouse position. I want it to keep it's initial position and reproduce the movement of the mouse. Like you said, i know how to make a sprite follow the mouse but i don't know how to make a sprite reproduce the mouse movement.

  • OK i finally found how to do it. I change this :

    ->Set MouseX to mouse.X-sprite.X

    ->Set MouseY to mouse.Y-sprite.Y

    Into this :

    ->Set MouseX to sprite.X-mouse.X

    ->Set MouseY to sprite.Y-mouse.Y

    Thanks a lot !

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