
To change the pointer image you will make the player spend lots of CPU because the program will use the method/event:on mouseWithin in the sprite script trigger and the mouse is always over the world (that is the sprite).
We will use the trick of the ray of the modelsUnderLoc method (the same used to capture clicks).
The trigger script now has two methods:
global avatarobj
on mouseWithin me --to capture the mouseover
cursor(-1) -- the normal image
set0=point(sprite(1).left,sprite(1).top)
pt0 = the mouseLoc - set0
m0 = sprite(1).camera.modelsUnderLoc(pt0, 3, #detailed)
if m0.count>1 then
if m0[1].model.name ="pic" OR m0[2].model.name ="pic" then
cursor (280) -- the "finger" image
end if
end if
end
on mouseUp me --to capture the click
set=point(sprite(1).left,sprite(1).top)
pt = the mouseLoc - set
m = sprite(1).camera.modelsUnderLoc(pt, 3, #detailed)
if m.count>1 then
if m[1].model.name ="pic" OR m[2].model.name ="pic" then
avatarobj.link=1
end if
end if
end
There are many pointer images numbers:
0 No cursor set
-1 Arrow (pointer) cursor
1 I-beam cursor
2 Crosshair cursor
3 Crossbar cursor
200 Blank cursor (hides cursor)
254 Help
256 Pencil
280 Finger
290 Closed hand
291 No-drop closed hand
292 Copy closed hand
302 Zoom in
303 Zoom out
etc. etc.
You can create a new image. We will have a lesson about this in the future.
Play the demo (again) going inside the building (the gallery), looking the "painting" and puting the cursor over it. Perhaps there are a bug - mine? - and the change-of-cursor only works until you go to the linked page. Is it a genial solution to not spend CPU? Sometimes nothing works :-(
PREVIOUS LESSON NEXT LESSON T. CONTENTS HOMEPAGE
