A behavior that gives a sprite kinetic motion and can be thrown around
From Cole Tierney"s Code Corner
http://homepages.together.net/%7Etierney/cole/code/
on beginSprite -- Start out drifting (just not going anywhere).
set deltaV = point( 0, 0 )
set state = #drifting
end
on mouseDown me -- Now change state to #dragging.
set mouseOffset = the loc of sprite spriteNum - point( the mouseH, the mouseV )
set state = #dragging
end
on exitFrame me
set pinnedLoc = point( the mouseH, the mouseV ) + mouseOffset
call( state, me ) -- Call whatever state we are in.
go the frame
end
-- State methods.
--
on dragging me
if NOT the mouseDown then
set state = #drifting -- Move back to drifting state.
set deltaV = pinnedLoc - lastLoc
else
set lastLoc = the loc of sprite spriteNum
set the loc of sprite spriteNum = pinnedLoc
end if
end
on drifting me
set the loc of sprite spriteNum = the loc of sprite spriteNum + deltaV
end
Contact
MMI
36 South Court Sq
Suite 300
Newnan, GA 30263
USA