Return To The Starting Position If It Doesn't Collide

Discussion in 'How Can I...?' started by Rodrigo Schneider, Jul 8, 2020.

  1. Rodrigo Schneider

    Rodrigo Schneider Boxer

    Joined:
    May 21, 2020
    Messages:
    18
    Likes Received:
    1
    Hello boxers!

    I'm making a very simple game for children. The player has to drag an Object1 onto an Object2. If he is unable to place Object 1 on top of Object2, Object1 must return to the starting position. If he succeeds, Object1 should play a sound, spin and disappear.

    I can do all of this, except return it to the starting position, in case the player is unable to place Object1 on top of Object2.

    Could you help me with that?
    Thank you!
     
  2. Vlad-NY

    Vlad-NY Serious Boxer

    Joined:
    Jul 21, 2018
    Messages:
    605
    Likes Received:
    361
    Hey there,

    If you are having troubles with this I suggest you to do the following:
    - when the user moves an object (on touchBegin ) save that object position (this.entity().position)
    - when released (on touchEnd) check if the position is correct i(additional logic followed here) otherwise move the entity to it's original position that you saved on touchBegin

    Following this simple rules would help you achieve your expected behaviour
     
  3. Rodrigo Schneider

    Rodrigo Schneider Boxer

    Joined:
    May 21, 2020
    Messages:
    18
    Likes Received:
    1
    Hello Vlad!
    Thank's for your time! This ("touchBegin", "this.entity (). Position", "touchEnd" etc.) seems to be EXACTLY what I need. That's the logic! However, my programming knowledge is very poor and I have no idea where I would do this implementation.
    If you can give me any directions or tips, I will be extremely grateful.
     

Share This Page