Setting a mouse position??

Get help using Construct 2

Post » Wed Dec 26, 2012 5:52 pm

Hello,

I have been trying to set a mouse position to a certain coordinates but cannot find a good solution.
I am making a game similar to those where you are a square in a maze and you have to pass through the level without touching the walls. So this square sprite is "set position to Mouse.X, Mouse.Y", so basically your mouse is the square. I need this square to be in the specific coordinates when the game starts (and also when the player dies and hits retry), that means I have to somehow make the mouse cursor appear where I want it to be, but I can't find any info on how to do that, any ideas?

Thanks
B
6
S
1
Posts: 32
Reputation: 789

Post » Wed Dec 26, 2012 7:25 pm

I'd suggest that you do it in two parts:

1) Instead of moving the mouse, have the user click inside a starting block to initiate the maze. That way, you're avoiding doing that which I don't think anyone would actually appreciate (moving their mouse), and you've basically worked around the issue (which I don't think is possible in C2; maybe there's a plugin that can be coded to do it though).
2) Once the maze has begun (i.e., the player has clicked in the starting area), set an action to change the mouse cursor to a sprite (Mouse -> set cursor from sprite) which can be your square or whatever you want. This effectively hides the mouse cursor when it's inside the game window. You can then set up an invisible block to follow Mouse.X and Mouse.Y at every tick, which is actually used to detect collisions with the maze walls.GeometriX2012-12-26 19:26:38
B
56
S
15
G
10
Posts: 910
Reputation: 11,972

Post » Wed Dec 26, 2012 7:29 pm

Yep, @GeometriX got it right.

Just so you know, it's actually impossible for an internet page to control your cursor (for obvious reasons).
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Wed Dec 26, 2012 8:24 pm

Thank you for responses guys,
Before I posted this, the game was already complete (and I did it exactly as GeometriX said). I just preferred to do it the way I described instead of the way I did it. I found one link saying that it is possible with some formula but the capx is no longer there, I guess the link is old. So I figured it is doable.. otherwise, the workaround is there but I preferred the other one,
Thanks again nevertheless!
B
6
S
1
Posts: 32
Reputation: 789


Return to How do I....?

Who is online

Users browsing this forum: spcsmrf and 27 guests