How do I teleport my cursor?

Get help using Construct 2

Post » Thu Jun 29, 2017 8:16 am

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 :D
B
3
Posts: 6
Reputation: 197

Post » Wed Jul 05, 2017 3:44 pm

You can't do that for security reasons.
https://stackoverflow.com/a/4752512/2555197
https://www.ravenheart.ca/home
Company name changed to avoid Facebook-type shenanigans

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
B
22
S
6
G
1
Posts: 1,415
Reputation: 4,824

Post » Thu Jul 06, 2017 4:43 pm

Well now i can't make mouse support for my first person game.
B
3
Posts: 6
Reputation: 197

Post » Thu Jul 06, 2017 9:56 pm

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!
The LEVEL GENERATOR TOOLKIT



24 functions dedicated to producing randomly generated terrain for all kinds of games.
B
25
S
7
Posts: 242
Reputation: 2,306

Post » Fri Jul 07, 2017 9:39 am

mrtumbles wrote: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
B
3
Posts: 6
Reputation: 197

Post » Fri Jul 07, 2017 11:39 am

Try teleporting the cursor.

Don't post again without a CapX.
The LEVEL GENERATOR TOOLKIT



24 functions dedicated to producing randomly generated terrain for all kinds of games.
B
25
S
7
Posts: 242
Reputation: 2,306

Post » Fri Jul 07, 2017 11:41 am

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



24 functions dedicated to producing randomly generated terrain for all kinds of games.
B
25
S
7
Posts: 242
Reputation: 2,306

Post » Fri Jul 07, 2017 11:42 am

And since your English is bad I'd recommend a 'thank you' is customary when someone volunteers help :)
The LEVEL GENERATOR TOOLKIT



24 functions dedicated to producing randomly generated terrain for all kinds of games.
B
25
S
7
Posts: 242
Reputation: 2,306

Post » Fri Jul 07, 2017 2:53 pm

It works, but now, when mouse hits the border nothing happens. That was the main problem ;/
B
3
Posts: 6
Reputation: 197

Post » Fri Jul 07, 2017 3:08 pm

Post a CapX, this will make it much easier for people to diagnose and solve your problem.
The LEVEL GENERATOR TOOLKIT



24 functions dedicated to producing randomly generated terrain for all kinds of games.
B
25
S
7
Posts: 242
Reputation: 2,306

Next

Return to How do I....?

Who is online

Users browsing this forum: David181, yiuyiu6666 and 29 guests