How do I teleport my cursor?

From the Asset Store
Mouse cursor is something that the player controls and sees all the time, that's why it is so important to make it cool!
  • Hey guys, I have game where i have to move my mouse.

    But when i move mouse to layout's corner, it has to teleport to other, like "Warp" behavior.

    How do i do this? Is there some plugins or other solutions? It can be sprite, not only mouse/cursor itself.

    Thank you for reading, and sorry for my bad english

  • You can't do that for security reasons.

    https://stackoverflow.com/a/4752512/2555197

  • Well now i can't make mouse support for my first person game.

  • You can simulate this by simulating a cursor, the result therefore only working within the game and circumventing the above security issue.

    Add a Cursor sprite.

    Have variables which track the X and Y of the Mouse. Call them MousePrevX & MousePrevY.

    Every tick:

    -> Set Cursor X to Self.X + ( Mouse.X - MousePrevX )

    -> Set Cursor Y to Self.Y + ( Mouse.Y - MousePrevY )

    Don't forget to use the Cursor's position rather than the Mouse's when judging things like what's being clicked on etc. Good luck!

  • You can simulate this by simulating a cursor, the result therefore only working within the game and circumventing the above security issue.

    Add a Cursor sprite.

    Have variables which track the X and Y of the Mouse. Call them MousePrevX & MousePrevY.

    Every tick:

    -> Set Cursor X to Self.X + ( Mouse.X - MousePrevX )

    -> Set Cursor Y to Self.Y + ( Mouse.Y - MousePrevY )

    Don't forget to use the Cursor's position rather than the Mouse's when judging things like what's being clicked on etc. Good luck!

    Cursor object appears below mouse and nothing more happens

  • Try teleporting the cursor.

    Don't post again without a CapX.

  • Oh, I did forget a step: after you've set the position of the Cursor, set the Mouse.PrevX/Y to Mouse.X/Y

  • And since your English is bad I'd recommend a 'thank you' is customary when someone volunteers help

  • It works, but now, when mouse hits the border nothing happens. That was the main problem ;/

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Post a CapX, this will make it much easier for people to diagnose and solve your problem.

  • OMG how do i do this? So hard interface there

  • I mean fuck you

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