Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
Arrow is not rotating — Gideros Forum

Arrow is not rotating

SarthakSarthak Member
edited August 2014 in General questions
Hi,
I am creating "Archery" type Game demo. in it i have used one power-slider, using that user needs to adjust the power, and there is one directional arrow, which continuously move within 0 to 90 degree, when user play on click button , the rotation of directional arrow is stopped, and as per its current angle, i have given linerimpulseforce to arrow, but after that it is not rotating as per its body, means while arrow is moving downwards because of gravity, the angle is not changed as per it, it moving downwards as it is, without rotation effect.

Please help me.


Thank you.

Comments

  • DiscipleDisciple Member
    Accepted Answer
    Do you mean that the arrow stays all the way with the same rotation as when you shoot it?

    If that's the case you need to get the x and y speeds and then find out the angle through math.atan2. I made a quick example.

    I guess you're getting the speed in x and the gravity with math.cos and math.sin when the shot is performed. So after the arrow is shot you'd have to determine the rotation by those given speeds.
    zip
    zip
    ArrowExample.zip
    3K

    Likes: Sarthak

    +1 -1 (+1 / -0 )Share on Facebook
  • SarthakSarthak Member
    edited August 2014
    Thank you very much for your quick reply.


    But i have used body, and i have given impulse force to that body, and in OnEnterframe, i have set the rotation of arrow's sprite with its body.

    I have attached my demo, in it first of all, you have to set the power, then click on play.

    Hope u will understand my problem, and help me for same.

    Thank you very much.


    zip
    zip
    ArcheryDemo 2.zip
    143K
  • DiscipleDisciple Member
    Accepted Answer
    I added some lines to your code and you can see how to get the angle.

    I haven't worked with Box2d so I'm not used to what was in there. Therefore I didn't find where to set the rotation for the actual arrow ("soccerball") but rather it was set to a rectangle sprite that is behind it, you'll see it when you run it. I'm sure you'll know how to set that rotation to the arrow though (y)
    zip
    zip
    ArcheryDemoMod.zip
    133K
  • SarthakSarthak Member
    edited August 2014
    Thank you very much...

    Such a you are truly genius, heads-off to you.

    It's working with body, and as you suggested, i have set angle of sprite(soccerball) , and its worked very well.


    Once again thank you very much.

    I have attached final demo.
    zip
    zip
    ArcheryDemo.zip
    152K

    Likes: Sarthak

    +1 -1 (+1 / -0 )Share on Facebook
  • Thanks for the head-off! :) I learned some things too.

    I'm glad I could help. I see it works now! (y)
Sign In or Register to comment.