The Daily Click ::. Forums ::. Klik Coding Help ::. Set cursor position.
 

Post Reply  Post Oekaki 
 

Posted By Message

Rob Rule

Rusten Crating

Registered
  22/12/2007
Points
  532
11th November, 2008 at 15:23:04 -

Dammit, having some problems. Ideally I want Counter = 0, set Cursor to Position 0,0 relative to Active 1. So when I change the counter's value, the cursor appears in a different area.

(Specifically, I'm making a menu system which is both cursor and arrow key controlled; when the arrow keys are in use, the cursor arrow will appear by each menu option ((start =0, continue = 1, options =2, the usual system)) like the old menu system arrow pointers, but can be moved free from that position if the player chooses to use their mouse. When pressing the keys again, the cursor will snap back to the correct position beside the menu option)

Things I've tried: Creating the cursor relative to the menu option (each word is an active object image), but the relative to option greys out whenever I click anywhere to change its position, in or out of the frame. When creating at actual x,y coordinates, nothing happens at runtime, but this is most likely because I'm creating the cursor object as opposed to moving the actual cursor's position.

I'm using the cursor object for a custom cursor. Any help is much appreciated. It's an idea I've wanted to do for a while and would love to get implemented.

Image Edited by the Author.

Image Edited by the Author.

 
It'll all blow over.

Pixelthief

Dedicated klik scientist

Registered
  02/01/2002
Points
  3419

Game of the Week WinnerWeekly Picture Me This Winner!You've Been Circy'd!VIP MemberI like Aliens!Evil klikerThe SpinsterI donated an open source project
11th November, 2008 at 18:16:08 -

AFAIK, the cursor object cannot *move* the cursor, only change the shape and picture of it, etc etc. You can accomplish most of the same things by simply using an active object instead of the cursor object, and making your cursor invisible at runtime. Actually this is a tricky little blighter of a situation to handle, however, I've happened to have done this before, because so few extensions actually set mouse coordinates. What you need is this:
http://ext.neatwares.ath.cx/ext/Mouse_Object

With that, you can set the *Actual* mouse X/Y positions. The drawback is that these coordinates are NOT relative to the game window, they are the actual X/Y coordinates on the computers screen. So in order to get X/Y in-game, you need to add the X & Y coordinates of the top-left of your game's window. You can retrieve these with the Windows Control Object, which I think is either built into MMF2 or comes with one of the packs.

So it looks like this:

Set Mouse Actual X position to (WinXPos + X)


one thing you should consider, however, is it is considered bad manners for *any* application to move your mouse onscreen. Its very annoying to try to exit a game that constantly positions your mouse in the center, like some naive ones do, but that probably won't be a matter for just moving on a menu. Just make sure to add some sort of qualifier to your code that disables it when the screen is minimized, because nothing is worse than having an application that is positioning your mouse even when the window doesn't exist.

Also, I happened to use a hybrid mouse/keyboard menu for Gridquest, if you check my sig. Even if you don't care to play it, you could download it just to see how I did the opening menu- I made it so that it would only give the mouse "control" of the menu when you MOVE the mouse, not when it is sitting still. So if the mouse is still, you can change the position with the keyboard, but if you move the mouse, it will go back to wherever the mouse was. Makes it work wonderful if the users are using with JUST the mouse or JUST the keyboard, not so hot if they use both.

 
Gridquest V2.00 is out!!
http://www.create-games.com/download.asp?id=7456

Rob Rule

Rusten Crating

Registered
  22/12/2007
Points
  532
11th November, 2008 at 18:24:49 -

Yeah, I've used the distance rolled condition of the mouse object so the mouse control group is only activated when/if the mouse is moved, and likewise, key control group is deactivated. Visa versa with keys pressed, luckily the code doesn't clash.

I've been having major issues with positioning the mouse correctly, and I've discovered the fact that it positions with reference to the computer screen, which was causing me a major headache. I'll check out the Windows control object now; I'm quite familiar with it luckily.

Also, the minimize tip is an important one, thanks.

The mouse control is used solely for the small splash screen 'config' screen display that initialises before many PC games play; otherwise mouse movement isn't used, I don't think it would lend itself to ingame menus too well.

Thanks for the detailed responses as always, 'thief.

Image Edited by the Author.

 
It'll all blow over.
   

Post Reply



 



Advertisement

Worth A Click