Search content:

 

Personal Menu
Username:
Password:
Save password

Become a member

Forgot Password?

 

Don't miss these
Jaw Wars
Color Dialog behavior
Domicilia
ADOxtra for Shockwave Multiuser Server
SpriTec Xtra! - Export your Cast and Score
Narration Tool
Wait For Frame Ready
SM sprite scroll
SpaceShooter
Graphing a Function
MediaMacros Xtras Mall
 

 

 

Behavior Rotate-a-Sprite

Added on 5/26/2000

 

Compatibilities:
behavior D7 D8 Mac PC Shockwave

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

 


Upload Provided by ABCUpload ASP

Contact

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

Fax - (206) 339-5833

Send e-mail