Setting a mouse position??

0 favourites
  • 4 posts
From the Asset Store
Creepy Sprite Font suitable font for your Dark/Horror/Halloween games.
  • 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

  • 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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Yep, GeometriX got it right.

    Just so you know, it's actually impossible for an internet page to control your cursor (for obvious reasons).

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

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