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
Wait for X seconds, go to marker
Help and Manual
Populate MS Combo Box ActiveX
DOMAJ Site and Forum
Hilite Lines - Text and Field
ini-script
Tabuleiro Nebulae MultiUserServer
Script Interface Tool
Removing the stage border
Hybrid CD
 

 

 

Behavior Drifter

Added on 7/1/1999

 

Compatibilities:
behavior D6_5 D7 D8 Mac PC

This item has not yet been rated

Author: ColeTierney

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/

property spriteNum, state, lastLoc, deltaV, mouseOffset, pinnedLoc

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

Send e-mail