modify mouse pointer?

Blitz3D Forums/Blitz3D Programming/modify mouse pointer?

matthews_30(Posted 2006) [#1]
i have a routine to click (left mouse click) an specific point and an image moves to this new position.

now what i need is to assign an animated image to the traditional mouse image (static white arrow).

in short, i want to replace the traditional static white arrow of the mouse for a new animated pointer.

is this possible?


GfK(Posted 2006) [#2]
Typed straight into replybox, so untested:
Graphics 800,600
HidePointer
SetBuffer Backbuffer()
Global imgMouse = LoadAnimImage("mouseimage.png",16,16,0,4)
Global mouseFrame = 0

While Not KeyDown(1)
  Cls
  DrawMouse()
  Flip
Wend

Function DrawMouse()
  DrawImage imgMouse,MouseX(),MouseY(),mouseFrame
  mouseFrame = mouseFrame + 1
  if mouseFrame > 3 Then MouseFrame = 0
End Function



matthews_30(Posted 2006) [#3]
i am sorry for this ne stupid question, but i tried to use it with an image called "mouseimage.png" wich is 16x48 (3 frames horizontaly) but it says "Image frame out of range" :(

do you know how to make it work? or am i doing something wrong?

thanks for your patience :)


KuRiX(Posted 2006) [#4]
Just change to this:

Global imgMouse = LoadImage("mouseimage.png")

Edited: for non animated, and what PCD says for animated


Baystep Productions(Posted 2006) [#5]
LoadAnimImage("mouseimage.png",16,16,0,3)

That should work, if it doesn't add a few more pixels to the end of the image strip.


Scherererer(Posted 2006) [#6]
you might have also needed to change the DrawMouse() function to say

If mouseFrame > 2 Then mouseFrame = 0

so that it doesn't go past frame 2 (0,1,2 = 3 frames)


n8r2k(Posted 2006) [#7]
beat me to it tainted :P


matthews_30(Posted 2006) [#8]
excellent! it worked like a charm!

this is the final code:

Graphics 800,600
HidePointer
SetBuffer BackBuffer()
Global imgMouse = LoadAnimImage("mouseimage.png",16,16,0,3)

Global mouseFrame = 0

While Not KeyDown(1)
Cls
DrawMouse()
Flip
Wend

Function DrawMouse()
DrawImage imgMouse,MouseX(),MouseY(),mouseFrame
mouseFrame = mouseFrame + 1
If mouseFrame > 2 Then MouseFrame = 0

End Function

thanks a lot!

B!