Android Question move object depend on angle.. LIBGDX

ilan

Expert
Licensed User
Longtime User
hi

can i move an image in libgdx to direction in angle??

like i have a car an i want it to move it straight forwoard now if i change the angle of the image it should go forwoard on this direction...

like in the picture..

1.png


is it possible? i want to draw the image in a specific angle and i would like to move it forwoard on this angle...

Batch.DrawRegion3(ballFrames(0,ballint) ,ball.x,ball.y,ball.w/2,ball.h/2,ball.w,ball.h,1,1,15)

does anyone know how to calculate the new x y depend on the angle?

maybe sinus cosinus??
 

walterf25

Expert
Licensed User
Longtime User
hi

can i move an image in libgdx to direction in angle??

like i have a car an i want it to move it straight forwoard now if i change the angle of the image it should go forwoard on this direction...

like in the picture..

View attachment 36222

is it possible? i want to draw the image in a specific angle and i would like to move it forwoard on this angle...

Batch.DrawRegion3(ballFrames(0,ballint) ,ball.x,ball.y,ball.w/2,ball.h/2,ball.w,ball.h,1,1,15)

does anyone know how to calculate the new x y depend on the angle?

maybe sinus cosinus??
I don't think there is any calculation that needs to be done, libGDX does this for you automatically, all you have to do is give it the angle value.
I'd have to think back, i've done this before but haven't used libGDX in such a while i'd have to dig some of my unfinished old projects.

One thing you can do is use the SCN2d class, this makes things a lot simpler.

Cheers,
Walter
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
I don't think there is any calculation that needs to be done, libGDX does this for you automatically, all you have to do is give it the angle value.
I'd have to think back, i've done this before but haven't used libGDX in such a while i'd have to dig some of my unfinished old projects.

One thing you can do is use the SCN2d class, this makes things a lot simpler.

Cheers,
Walter

it would be great if you could find a simple example for me (in your old unfinished projects) that show how i can do it... thanks :)
 
Upvote 0

walterf25

Expert
Licensed User
Longtime User
it would be great if you could find a simple example for me that show how i can do it... thanks :)
I'll try to find something, i'll let you know!
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
did you check a Steering Behaviors from Informatix? I think that can solve your problem.

No, i did not knew such thing exist. Its unbelievable how much libs and examples informatix has uploaded to this forum.

Thank you james for your help i will take a look at it...:)
 
Upvote 0

walterf25

Expert
Licensed User
Longtime User
did you check a Steering Behaviors from Informatix? I think that can solve your problem.
Yes, i totally forgot about this library, yes you can definitely use steering behaviors for what you want to achieve, and it would make things way easier too.

Good Luck!
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
did you check a Steering Behaviors from Informatix? I think that can solve your problem.

james this is exactlly what i was looking for.

you know lot of times i say to myself i am happy i found B4A
today i said to myself i am happy @Informatix found B4a :D

wonderfull lib and lots of great example in it!! thank you very much!!
 
Last edited:
Upvote 0

RandomCoder

Well-Known Member
Licensed User
Longtime User
You should place an @ in front of user names so that they receive an alert and are made aware of your post. That way @Informatix will see your post and know how valued a member he is :D
 
Upvote 0
Top