Android Flicking an object towards a direction

Discussion in 'Programming' started by Mael, Feb 12, 2019.

  1. Mael

    Mael Member

    Joined:
    Feb 12, 2019
    Posts:
    6
    Hello everyone!

    I'm quite new to the mobile programming and now stuck on a problem. My goal is to be able to flick an object, like a ball, that moves then towards the direction of the flick.

    I tried to implement this with the event "Flick" and then point towards direction "diff X and diff y". And then set speed 5.

    Sadly the game crashes every time with the argument that diff X has never been seen before.

    Can maybe someone explain me how to do it correctly?

    Thank you very much.
     
  2. Alexx

    Alexx Member

    Joined:
    Jun 21, 2016
    Posts:
    436
    You will need to post the code!
     
  3. SnotWaffle Studios

    SnotWaffle Studios Member

    Joined:
    Jun 21, 2016
    Posts:
    288
    Check the documentation for "Gesture Flick." You need to extract the diffX and diffY from a ds_map called event_data:
    Code:
    flickVelX = event_data[?"diffX"];
    flickVelY = event_data[?"diffY"];
    
    You can rename those variables to whatever you want. Or even just replace them with hspeed and vspeed.

    Here is the full flick example from the documentation:
     
    Mael and Bentley like this.
  4. Mael

    Mael Member

    Joined:
    Feb 12, 2019
    Posts:
    6

    thank you very much sir! :)
     
    SnotWaffle Studios likes this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice