Simple Mouse Cursor

A simple question:

When I position a DirectLabel based on the mouse position I need todo this:

if base.mouseWatcherNode.hasMouse():
    self.cursor.setPos(1.33*x, 0, y)

What is the easiest way to get the aspect ratio for the window? Are there a couple of nice funcitons that give me the current window height and width?

If you look in direct/showbase/ you will find a function called getAspectRatio() I forget what you need to pass in :frowning:

Also, there is a function called enableSoftwareMouse or something which shows you how to setup a software mouse pointer.

Sorry I cant be more specific at the moment, but hopefully this will put you on the right tracks.

That was me. Forgot I was not logged in.

Right, Im home I can construct a real reply now :slight_smile:

To get the aspect ratio for the main window use…


Or, if this is for a different window then use…


Now the fun bit. Try this out…


The code for this is handy to know ( taken from )…


        Creates some geometry and parents it to render2d to show
        the currently-known mouse position.  Useful if the mouse
        pointer is invisible for some reason.
        mouseViz = self.render2d.attachNewNode('mouseViz')
        lilsmiley = loader.loadModel('lilsmiley')

        aspectRatio = self.getAspectRatio()
        # Scale the smiley face to 32x32 pixels.
            32.0 / / aspectRatio,
            1.0, 32.0 /

If you will use a similar scale, then remember to change the to

Hope this helps!

Thanks Sandman, thats exactly what I needed.