Contents
Articles
Behaviors
Books
Director News
Director Web Sites
FAQ
Games
Mailing Lists
News Groups
Project Examples
Reviews
Software
Tools
Useful Web Sites
Utilities
Xtras

Don't miss these
Paste Behavior (Ctrl + V)
3 State Button
Golden Gate
Back Button
Hold Till Flash Directmedia finishes playing
Dragging multiple sprites
Simple Paint application
Media Development
WebViewer Xtra
VideoCodecCheck II
 

 

 

Behavior SM sprite scroll

Added on 4/15/2000

 

Compatibilities:
behavior D7 D8 Mac PC Shockwave

This item has not yet been rated

Author: BrentMoseley

Part 1/3 of the Scrolling menu set. You must use this behavior in conjunction with the "SCROLL CONTROL" behavior. Attach this to the sprites that you want to scroll. Set "starting speed" and "starting accel" all other parameters are set with the "SCROLL CONTROL" behavior.

--Sprite Scroll part 1/3 of the Scroll Menu set.
--Created by Brent Moseley April 2000
--brent099@xoommail.com


property mysprite
property moveinc
property movechange
property maxspeed
property oldmax
property startmax
property startaccel

on beginsprite me
  mysprite = the spritenum of me
  movechange = startaccel
  maxspeed = startmax
  moveinc = 0
end


on prepareframe me
  
  if the loch of sprite mysprite > the width of the rect of the stage + 150 then  --RIGHT
    the loch of sprite mysprite = -150
  end if
  -- |
  -- | If the sprite goes off the screen then set it back on the other side
  -- |
  if the loch of sprite mysprite < -150 then
    the loch of sprite mysprite = the width of the rect of the stage + 150  --LEFT
  end if  
  
  
  -- if it"s moveing right.
  if movechange > 0 then  
    if moveinc < maxspeed then  -- if it"s going slower than target speed.
      moveinc = moveinc + movechange --accelerate
    else if moveinc > maxspeed then  -- if it"s going faster than target speed.
      moveinc = moveinc - movechange --decelerate
    end if
  end if
  
  -- if it"s moveing left.
  if movechange < 0 then  
    if moveinc > -maxspeed then     --|same as above.
      moveinc = moveinc + movechange--|
    else if moveinc < -maxspeed then--|
      moveinc = moveinc - movechange--|
    end if
  end if
  
  the loch of sprite mysprite = the loch of sprite mysprite + moveinc  --moves the sprite
end

--called by the "scroll control" behavior.
--sets the speed acceleration.
on setmoveinc me ,a ,b
  movechange = a --acceleration/deceleration speed
  maxspeed = b --maximum(target) speed
end


--called by the optional "scroll slow down" behavior.
--It slows the sprites down regardless of their direction.
on goslow me ,a
  oldmax = maxspeed
  
  if maxspeed > 0 then
    maxspeed = a
  else
    maxspeed = -a
  end if
end

--Sets the speed back to normal.
on gonormal me
  maxspeed = oldmax
end


on getBehaviorDescription
  return "Use this behavior in conjunction with the "SCROLL CONTROL" behavior" & RETURN & RETURN &
"Attach this to the sprites that you want to scroll" & RETURN &
"Set "starting speed" and "starting accel" all other parameters are set with the "SCROLL CONTROL" behavior"
end



on getPropertyDescriptionList me
  set pdlist to [:]
  addprop pdlist, #startmax, [#comment:"starting speed", #format:#integer, #default:3]
  addprop pdlist, #startaccel, [#comment:"starting acceleration", #format:#float, #default:.5, #range: [#min:-2, #max:2]]
  return pdlist
end getPropertyDescriptionList

 


Contact

MMI
36 South Court Sq
Suite 300
Newnan, GA 30263
USA

Send e-mail