Search content:

 

Personal Menu
Username:
Password:
Save password

Become a member

Forgot Password?

 

Don't miss these
MouseWheel
How do I check if a user has the needed fonts on their machine?
Turn puppeting off for a range of sprite channels
JTMR Yo Style Writer
Pulling in Those Graphics
Buddy Saver
Glu32
Brain Killer (Simon)
Set DirectToStage of a Animated Gif Sprite
Generic behavior to copy a file
MediaMacros Xtras Mall
 

 

 

Behavior Rolling Ball

Added on 9/6/1999

 

Compatibilities:
behavior D7 D8 Mac PC Shockwave

Rating:

Author: MediaMacros (website)

This behavior can be dropped on a bitmap ball to make it roll across a plane.

--Copyright 1999 Chuck Neal
--chuck@mediamacros.com
--If you find this code helpful, send me an e-mail and let me know. :-)
property spriteNum, diameter, baseH, constraintSprite

on getPropertyDescriptionList me
  p_list = [:]
  p_list.addProp(#constraintSprite, [#format : #integer, #comment : "Sprite to roll on:", #default : (the currentSpriteNum + 1)])
  return p_list
end

on beginSprite me
  diameter = sprite(spriteNum).height
  baseH = sprite(spriteNum).locH
end

on mouseDown me
  startMouseH = the mouseH
  startSpriteH = sprite(spriteNum).loch
  repeat while the stillDown
    hOffset = the mouseH - startMouseH
    newLocH = startSpriteH + hOffset
    if newLocH < sprite(constraintSprite).left then
      newLocH = sprite(constraintSprite).left
    else if newLocH > sprite(constraintSprite).right then
      newLocH = sprite(constraintSprite).right
    end if
    --get the rotation
    percentage = (newLocH - baseH) / (diameter * pi)
    sprite(spriteNum).rotation = 360 * percentage
    sprite(spriteNum).locH = newLocH
    updateStage
  end repeat
end

on getBehaviorDescription me
  return "This is a simple behavior for rolling a ball along a flat surface. Drop it on the bitmap sprite for the ball and assign the constraint sprite."
end

 


Upload Provided by ABCUpload ASP

Contact

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

Fax - (206) 339-5833

Send e-mail