A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Particle Question: how to attach...

Hybrid View

  1. #1
    Member
    Join Date
    Dec 2005
    Posts
    60

    Particle Question: how to attach...

    Hi, if somebody could solve my problem, I finally can start creating levels for my game. Almost everything is done, only the ragdollphysics. The ragdolls itself are done, but I need to attach limb pictures etc... to the ragdoll

    I'm using the Flade physics engine (http://www.cove.org/flade)
    There you can download flade and the most usefull thing for me is that you create two particles and attach a stupid drawing to it (for example a woodblock). So that the block follows the constraint between the particles, got it?

    Here's an example of the ragdoll (simple) that I created with Flade : http://sniperware.50webs.com/ragdoll.swf

    My question is pretty hard isn't it? I tried everything!
    Please help!

  2. #2
    Senior Member ozmic66's Avatar
    Join Date
    Oct 2005
    Posts
    472
    Lets say, for example, the upper arm of your ragdoll extends from 'pointA' (shoulder) to 'pointB' (elbow)

    to attach a movie clip to that, try doing the following thing:

    (i'm assuming that the axis of the movieclip is where the arm is supposed to turn(shoulder))

    1. position the movieclip at pointA.x,pointA.y

    2. ang = getAngle(pointA,pointB) //in degrees

    3. movieclip._rotation = ang //add or subtract from this value to correct for angle offset

    im guessing you know how to find the angle between two points

  3. #3
    Member
    Join Date
    Dec 2005
    Posts
    60
    No, i dont
    thanks for the help.

  4. #4
    Senior Member ozmic66's Avatar
    Join Date
    Oct 2005
    Posts
    472

    try this

    Code:
    function getAngle(pA,pB){
      var xDiff=pA.x-pB.x
      var yDiff=pA.y-pB.y
      var radians = Math.atan2(yDiff, xDiff);
      if (yDiff<0) {
        radians += (2*Math.PI);
      }
      radians-=Math.PI
      degrees = radians*(180/Math.PI)
      return degrees
    }
    good luck

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center