I have a question about a ball game i am making.

I was wondering how to make it so that when you tap on the ball; what ever angle your finger hits the ball at, the ball goes off at that angle and not just in a straight line.

Best Answer

  • FajlajpFajlajp Posts: 666
    edited July 2013 Accepted Answer
    I think you mean flick movement. This is how to. (This will also have the speed depending on your swipe speed,but that's is just optinal)
    Use the "change velocity" behaviour in the ball actor.
    In dirrection you do:(
    (self.position.x-mouse.position.x,self.position.y-mouse.position.y)
    -In speed you do : (You could enter the speed you want if you don't want the speed to be depending on the swipe speed)
    magnitude(self.position.Y,mouse.positionY)*3

    now the *3 can be adjusted to the power you like for your game

    That should work,but I haven't test it.

Answers

  • captain-cheesycaptain-cheesy Member Posts: 7
    thanks it works!!!
  • captain-cheesycaptain-cheesy Member Posts: 7
    My only question now is how do you make the ball slow down when you arent touching the ball
  • -Timo--Timo- Member Posts: 2,313
    make a timer and say for 0.1 seconds accelerate to (Im not sure what you exactly want but I think this should work)
  • captain-cheesycaptain-cheesy Member Posts: 7
    I think you mean flick movement. This is how to. (This will also have the speed depending on your swipe speed,but that's is just optinal)
    Use the "change velocity" behaviour in the ball actor.
    In dirrection you do:(
    (self.position.x-mouse.position.x,self.position.y-mouse.position.y)
    -In speed you do : (You could enter the speed you want if you don't want the speed to be depending on the swipe speed)
    magnitude(self.position.Y,mouse.positionY)*3

    now the *3 can be adjusted to the power you like for your game

    That should work,but I haven't test it.
    It works fine left and right but the ball wont go up when i touch it


Sign In or Register to comment.