Android Question move object depend on angle.. LIBGDX

Discussion in 'Android Questions' started by ilan, Jul 27, 2015.

  1. ilan

    ilan Expert Licensed 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??
     
  2. walterf25

    walterf25 Well-Known Member Licensed 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
     
  3. ilan

    ilan Expert Licensed User

    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 :)
     
  4. walterf25

    walterf25 Well-Known Member Licensed User

    I'll try to find something, i'll let you know!
     
    ilan likes this.
  5. Jaames

    Jaames Active Member Licensed User

    ilan likes this.
  6. ilan

    ilan Expert Licensed User

    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...:)
     
    Jaames likes this.
  7. Jaames

    Jaames Active Member Licensed User

    I know. And B4A would not be the same without him, hat down and millions of thanks from me. In my opinion, he should be awarded in some way...
     
    Informatix and ilan like this.
  8. ilan

    ilan Expert Licensed User

    Lord informatix :cool:
     
    Jaames and Informatix like this.
  9. Informatix

    Informatix Expert Licensed User

    Yes, Steering Behaviors is what I use myself to move sprites.
     
    Jaames likes this.
  10. walterf25

    walterf25 Well-Known Member Licensed User

    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!
     
  11. ilan

    ilan Expert Licensed User

    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: Jul 28, 2015
    Jaames and RandomCoder like this.
  12. RandomCoder

    RandomCoder Well-Known Member Licensed 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
     
    Jaames, fireday and ilan like this.
  13. ilan

    ilan Expert Licensed User

    putting a @ in front of a user name will send him an alert?? i didnot knew that too... (man i am here almost 3 years and know nothing :confused:)
     
    fireday and inakigarm like this.
Loading...