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
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.
Likes: Sarthak
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.
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)
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.
Likes: Sarthak
I'm glad I could help. I see it works now! (y)