Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mouse click on an image

Status
Not open for further replies.

CodeHunter

Technical User
Dec 13, 2002
6
US
Ok, I understand that you can use a sprite with the mouse
with the Sprite 1,mousex(),mousey(),1. This is all and find, but how do I get that now new controlled sprite as a mouse to click on another image and have it do an action?

Ex: If mouse click on sprite then goto end
End:
Print "test worked"
end
can anyone answer this question of mine?
 
1: get the width and height of your sprite. (i always do it this way:
load bitmap "bmp.bmp",1
bx=bitmap width(1)
by=bitmap height(1)
get image 1,0,0,bx,by
sprite 1,x,y,1
2: well, the code off course-->
(in a loop)
if mousex()>spritex-bx/2 and mousex()<spritex+bx/2
if mousey()>spritey-by/2 and mousey()<spritey+by/2
if mouseclick()=1 and hold=0 then hold=1 : goto end
endif
endif
if mouseclick()=0 then hold=0

(and then after the loop)

end:
print "test worked"
suspend for key
end
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top