A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: x and y velocity question positioning

  1. #1
    Senior Member
    Join Date
    Feb 2005

    x and y velocity question positioning

    in my game i started, all i have right now is a warrior (the main character).
    There are 4 movie elements right now, the warrior, sword, hand1, and hand2.

    i also have 2 keyboard elements controling the character and the sword's attack.

    ok, my element hand1 is my characters left hand and hand2 is his right.

    I am having trouble with the swords attack move (in my swordsattack keyboard element), where i am using this script when i press the space bar:

    element ("Sword").x=element ("hand2").x
    element ("Sword").y=element("hand2").y
    element("Sword").velocity.x=element("hand2").veloc ity.x
    element("Sword").velocity.y=element("hand2").veloc ity.y

    and when i am not pressing the space bar :

    element ("Sword").x=element ("hand1").x
    element ("Sword").y=element("hand1").y
    element("Sword").velocity.x=element("hand1").veloc ity.x
    element("Sword").velocity.y=element("hand1").veloc ity.y

    what i am trying to do, is when i am not pressing the space bar the sword is in my characters left hand, and when i am holding the space bar, the sword is in my characters right hand ready to attack villians comming at him.

    the problem is, is that when i hold space to switch the sword over to my characters right hand, it goes way to far out, its hard to explain but ill give my file so when u press play and press space to attack, u will see what i mean.

    if u find out a way i can get the swords closer to my characters hands, please tell me,

    Attached Files Attached Files

  2. #2
    Game Master ConnELITE's Avatar
    Join Date
    Apr 2005
    United States, DC
    the problem was that the "center" of your sword, hand1, hand,2 and warrior were not where they were suppose to be. Because each element is a movie, the defoault center is in the center of the movie rather then the object itself. To replace the center you must click the object you want to replace the center on, then click the top icon on the left of 3dfa which looks like a cross. Then you will be able to click on the center point and move where you want. I fixed it in this download below, and next time i wouldnt recomend making each element a seperate movie. If you want to kno more about center points, Blanius toches briefly on them in his "online turtoil thread" under "collision detection" or something.
    Attached Files Attached Files

  3. #3
    Senior Member
    Join Date
    Feb 2005
    ok thanks a lot!

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