Search content:

 

Personal Menu
Username:
Password:
Save password

Become a member

Forgot Password?

 

Don't miss these
Cycle Fades of Images and Text
Get the computer name of user
EXE Screen Saver
Move and/or Zoom with ease settings
Add to the back list
Xtrema - Unicode String Class [ public beta ]
Dir Player
Draw a line with lingo
NailPolish
3state Button with Cursor change
MediaMacros Xtras Mall
 

 

 

Behavior Move sprite along mouse vector Behavior

Added on 4/29/2000

 

Compatibilities:
behavior D7 D8 Mac PC Shockwave

This item has not yet been rated

Author: DirkEismann

Moves any sprite(s) relative to the "mousevector" (the x/y change of the mouseLoc measured each frame)

-- Move sprite along mouse vector Behavior
-- © 28-04-2000, by dirk eismann
-- d.eismann@medienkonzepte.de
-- feel free to use it in your projects
-- please send me a line if you modify it in a way that enhances its functionality


property pSprite
property pLoc
property pVector
property pEndLoc
property pStartLoc
property pStop


on beginSprite me
  -- sprite reference
  pSprite = sprite(me.spritenum)
  -- sprite position reference
  pLoc = pSprite.locH
  
  -- for calculating the mouse movement
  pStartLoc = the mouseLoc
  pEndLoc = pStartLoc
  
  -- current vector
  pVector = point(0,0)
end beginSprite


on prepareFrame me
  -- store the current mouse position
  pStartLoc = the mouseLoc
end prepareFrame


on exitFrame me
  
  -- as soon as the mouse stops, store the new position
  if the lastRoll > 4 then
    pEndLoc = the mouseLoc
  end if
  
  if pStartLoc <> pEndLoc then
    
    pVector = pStartLoc - pEndLoc
    -- because the sprite may behave strange if the movement is minimal
    -- the vector is set to 0,0 if one component"s value is 1 or less
    if pVector[1].abs <= 1 and pVector[2].abs <= 1 then
      pVector = point(0,0)
    end if
    
  end if
  
  pSprite.loc = pSprite.loc + pVector
  
  if pStop then
    -- if the sprite should stop immediately, set the vector back to 0,0
    pVector = point(0,0)  
  end if
  
end exitFrame


on getPropertyDescriptionList
  description = [:]
  description.addProp(#pStop,[#comment:"Stop movement if mouse stops movement:",#format:#boolean,#default:false])
  return description
end getPropertyDescriptionList


on getBehaviorDescription me
  
  descriptionText = ""
  put "Move sprite along mouse vector Behavior, © 28-04-2000, by dirk eismann, d.eismann@medienkonzepte.de" & RETURN after descriptionText
  put "---------------------------------------------------------------------------------------------------" & RETURN after descriptionText
  put "Drop on any sprite(s)." & RETURN after descriptionText
  put "Everytime the mouse position changes, the sprite"s position is" & RETURN after descriptionText
  put "updated relative to the new mouse position." & RETURN after descriptionText
  put RETURN after descriptionText
  put "There is currently one parameters that can be edited in" & RETURN after descriptionText
  put "the getPropertDescriptionList dialogue:" & RETURN after descriptionText
  put RETURN after descriptionText
  put "pStop: boolean value. If set to true, the sprite stops movement" & RETURN after descriptionText
  put "          when the mouse "sleeps". otherwise the sprite keeps" & RETURN after descriptionText
  put "          on moving until the mouse position changes." & RETURN after descriptionText
  put "---------------------------------------------------------------------------------------------------" & RETURN after descriptionText
  
  return descriptionText
  
end getBehaviorDescription

 


Upload Provided by ABCUpload ASP

Contact

MMI
22 West Court Sq
Suite 2C
Newnan, GA 30263
USA

Fax - (206) 339-5833

Send e-mail