RayNerts wrote
> I'm having trouble understanding exactly how the clickOn function works.
>
> I noticed that the clickOn won't work on regular sprites without a behavior
> attached to them (as the help documentation points out), but it WILL work on
> animated gifs without an attached behavior. Is there some reason for this?
> And is there a better way to detect what sprite a user clicks on without
> giving it a behavior? (The help suggests assigning "a placeholder script to
> it ('- -,' for example)," but I don't get that.)
Hi
I rarely use the clickOn function - mainly because in most cases its better
to use a behaviour to handle the mouseDown and mouseUp events directed at
the sprite the behaviour is attached to (and since the sprite needs to have
a script attached to it anyway to get the clickon). On the rare occasions
when a behaviour was not appropriate, I've done something like
on getClickOn -- good for copy-ink sprites
p = the mouseLoc
repeat with j = the lastChannel down to 1
if inside(p, sprite(j).rect then return j
end repeat
return 0
end
or if you have irregular shaped sprites with matt ink, using a basic
behaviour like this to evoke a moviescript of frame script or object method.
property spriteNum
on mouseUp me
sendAllSprites(#clickedOn, spriteNum) -- send message to sprites
-- or send the message to a movieScript with ClickedOn(spriteNum)
-- or message an object with gObject.mHandleClickOn(spriteNum)
end
or if you are interested in the member that was clicked, use the mouseMember
or if you are developing a grid game and want to know which grid was
clicked, then using some dodgy maths, a bit like this -
on getCLickedRect pMouseLoc
column = pMouseLoc[1] / gColumnWidth
row = pMouseLoc[2] / gRowHeight
clickedSprite = worked out based on position in grid
return clickedSprite
end
Hope this helps,
Luke
--
__________________________________________________________________________
Mecca Medialight Pty Ltd
Mecca Medialight: Medialight Sound Studio:
111 Moor Street 1 Bakehouse Lane
Fitzroy, Vic. 3065 North Fitzroy, Vic. 3068
Tel +613 9416 2033 Tel +613 9416 2033
Fax +613 9416 2055 Fax +613 9416 2055
http://www.medialight.com.au
__________________________________________________________________________
[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/LUJ/lingo-l.cgi To post messages to the list,
email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED])
Lingo-L is for learning and helping with programming Lingo. Thanks!]