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
Planet Orbiter
Format Image
De-Xplode that text position relative
Beatnik Xtra
XML Socket Server for Flash, Director and Authorware
Increase/ Decrease FrameRate of a Flash Member
Number of Days in a Month
Yes/No Alert
Base64 Xtra
Pauseable Timer with Progress Bar
 

 

 

Behavior Simple projectile with gravity

Added on 12/18/2000

 

Compatibilities:
behavior D7 D8 Mac PC Shockwave

Rating:

Author: BarrySwan (website)

Allows a member to scroll over the movie, by defined parametres...

--Description
--------
--Drop onto a sprite to give it simple movement based on a firing angle,
--direction, and speed, as well as controlling gravity.


--Code
-------
property pSpeed
property pAngle, pDirection
property pX, pY
property pDX, pDY
property pGravity
property pS

on beginSprite me

  -- Initialise variables
  pS = sprite(me.spriteNum)
  pX = float(pS.locH)
  pY = float(pS.locV)

  -- Calculate movement vector
  pDX = sin(pAngle / 180.0 * pi()) * pSpeed
  pDY = -cos(pAngle / 180.0 * pi()) * pSpeed

  -- Flip X direction if wanting to move left
  if pDirection = #left then pDX = -pDX

end

on prepareFrame me

  -- Update variables
  pX = pX + pDX
  pY = pY + pDY
  pDY = pDY + pGravity

  -- Update sprite position
  pS.loc = point(integer(pX), integer(pY))

end

on getPropertyDescriptionList me
  -- Set up data
  tlData = [:]
  tlData[#pSpeed] = [#comment: "What speed? (In pixels per update)", #format: #float, #default: 10.0]
  tlData[#pAngle] = [#comment: "What angle? (0 = horizontal, 90 = vertically up)", #format: #float, #default: 45.0]
  tlData[#pDirection] = [#comment: "Fire left or right?", #format: #symbol, #default: #right, #range: [#left, #right]]
  tlData[#pGravity] = [#comment: "Gravity strength? (In pixels per update)", #format: #float, #default: 0.5]
  -- Return data
  return tlData
end

 


Contact

MMI
36 South Court Sq
Suite 300
Newnan, GA 30263
USA

Send e-mail