This behavior will move a sprite at a "speed" left or right depending on where the mouseH / cursor is relative to the centerpoint of the stage.
-- ScrollSpriteByMouseLocH
-- This behavior will move a sprite at a "speed"
-- left or right depending on where the mouseH / cursor is
-- relative to the centerpoint of the stage.
-- If the curor is more to the right, it will move the sprite to right.
-- When the cursor is closer to the right edge it
-- will move the sprite faster to the right.
-- If the cursor is more to the left, it will move to left.
-- When the cursor is closer to the left edge it
-- will move the sprite faster to the left.
-- The speed parameter determines how fast it will move,
-- relative to the cursor position on the screen.
property pi_theSprite -- Contains the number of the sprite we are moving- integer
property pi_stageWidth -- Contains the width of the stage we are on- integer
property pi_Speed -- Contains the amount to move each time- integer
property pi_Stagemiddle -- Contains the loch of the middle of the stage- integer
property ps_Speed -- Contains the string description of speed from parameter - string
on beginsprite me
set pi_theSprite = the spritenum of me
set pi_stageWidth = the stageright - the stageleft
set pi_stageMiddle = pi_stagewidth / 2
CHECKSPEED()
end beginsprite
on enterframe me
if the mouseh >= pi_stagemiddle then
set i_amounttomove = (-1 * (pi_stagemiddle - the mouseh))/ pi_speed
set the loch of sprite pi_theSprite = the loch of sprite pi_theSprite ¬
+ i_amounttomove
if the left of sprite pi_theSprite > pi_StageWidth then
set the loch of sprite pi_theSprite = 0 - (the width of ¬
sprite pi_thesprite / 2)
end if
else
set i_amounttomove = (pi_stagemiddle - the mouseh) / pi_speed
set the loch of sprite pi_theSprite = the loch of sprite pi_theSprite ¬
- i_amounttomove
if the right of sprite pi_theSprite < 0 then
set the loch of sprite pi_theSprite = pi_stagewidth + ¬
(the width of sprite pi_thesprite / 2)
end if
end if
end enterframe
on checkspeed me
case ps_speed of
"fastest" : set pi_speed = 1
"veryfast" : set pi_speed = 3
"prettyfast": set pi_speed = 5
"fast": set pi_speed = 7
"fastestmedium" : set pi_speed = 9
"fastmedium" : set pi_speed = 11
"medium": set pi_speed = 15
"slowmedium": set pi_speed = 20
"slower": set pi_speed = 30
"slow": set pi_speed = 40
"really slow": set pi_speed = 50
"slowest": set pi_speed = 75
"molasses": set pi_speed = 100
"slug": set pi_speed = 150
"slug in molasses": set pi_speed = 200
"cold slug in molasses": set pi_speed = 300
otherwise set pi_speed = 11
end case
end checkspeed me
on getPropertyDescriptionList me
set pl_proplist = [:]
addProp pl_proplist,#ps_Speed,[#default:"fastmedium",
#format:#string,#range: ["fastest","veryfast","prettyfast", "fast",
"fastestmedium" , "fastmedium", "medium", "slowmedium", "slower", "slow",
"really slow","slowest","molasses","slug", "slug in molasses", "cold slug in
molasses"] ,#comment:"How fast should the sprite move?"]
return pl_proplist
end getPropertyDescriptionList
on getBehaviorDescription me
set ps_string to "ScrollSpriteByMouseLocH"&return&"By Loren Mork. LMork@aol.com, LMork@accessone.com, Seattle/ Washington/U S A."&return&return& "This behavior will move a sprite at a speed left or right depending on where the mouseH / cursor is relative to the centerpoint of the stage."&return&return&"If the curor is more to the right, it will move the sprite to right. When the cursor is closer to the right edge it will move the sprite faster to the right. "&return&return&"If the cursor is more to the left, it will move to left. When the cursor is closer to the left edge it will move the sprite faster to the left." &return&return&"The speed parameter determines how fast it will move relative to the cursor position on the screen."&return
return ps_string
end getBehaviorDescription me
Contact
MMI
36 South Court Sq
Suite 300
Newnan, GA 30263
USA