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
 Colour Conversions Galore! Director Publications Function Key Keycodes ZGTSB-ButtonDown Message Box Behavior Director in Other Programs CatEffects pack JTMR Digital Painter Director Web Disable/Enable-Disk Errors,Task Switching,Screen saver,Task Bar

# Rotate-a-Sprite

 Compatibilities: This item has not yet been rated

Author: DirkEismann

Use on sprites to make them rotate around a given point.

 -- Rotate-a-Sprite -- use on sprites to make them rotate around a given point -- the radius is calculated by the sprite"s distance from -- the center point. Speed and direction is adjustable. -- by dirk eismann, d.eismann@medienkonzepte.de property pSprite property pRadius property pCenter property pDpF property pRad property pDir on beginSprite me   pSprite = sprite(me.spriteNum)      -- the distance from the center   x = pCenter[1] - pSprite.loc[1]   y = pCenter[2] - pSprite.loc[2]      -- get the radius   pRadius = sqrt((x*x)+(y*y))   -- angle towards the center   pRad = atan(-x,-y)      -- how the sprite moves   if pDir = #left then       pDpF = pDpF * pi / 180.00   else     pDpF = - pDpF * pi / 180.00   end if end beginSprite on exitFrame me   -- add the per-frame change to the current rad-value   pRad = pRad + pDpF   -- update the sprite"s position   pSprite.loc = point(pRadius * sin(pRad),pRadius * cos(pRad)) + pCenter end exitFrame on getPropertyDescriptionList   description = [:]   description.addProp(#pCenter,[#comment:"Rotate around point:",#format:#point,#default:point(100,100)])   description.addProp(#pDpF,[#comment:"Speed (degrees per frame):",#format:#integer,#range:[#min:1,#max:360],#default:1])   description.addProp(#pDir,[#comment:"Direction:",#format:#symbol,#range:[#left,#right],#default:#right])   return description end getPropertyDescriptionList

 Contact MMI 36 South Court Sq Suite 300 Newnan, GA 30263 USA Send e-mail