how to select sprite and move via touch to another location

0 favourites
  • 6 posts
From the Asset Store
Forget about default textbox restrictions, you can create sprites atop of the textbox
  • Hello,

    I want to be able to select a sprite which is the dog sprite pictured below, and then move that dog sprite to another area on the purple background by touch.

    So if i touched the dog sprite and then I touched the right corner of the purple background the dog sprite would move to that location. I have bullet and touch behaviours already, and the first part would be either on touch sprite or on tap object? then actions i do now know how to implement.

    Any suggestions appreciated,

    Thank you


  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Hello.

    I managed to do something in Construct 3 right now, and I hope it helps you.

    From what I understand you want to select an object on the screen, and then move that object and only that object anywhere on the screen by touch.

    Here you have a little example with two events.

    In the image above you can see an object named Sprite2. This object is the same with the dog object from your example.

    I added an instance variable "is_selected" to Sprite2 with the default value of 0.

    I added the Touch to the project.

    And as you can see from the image, when the Sprite2 object is tapped, is_selected takes the value of 1.

    If now you tap anywhere on the screen and is_selected is 1, the Sprite 2 object will change it's position to where you tapped (Touch.X, Touch.Y).

    Hope this help and if you have any more questions don't hesitate to ask them :D

    Have a nice day.

  • Set Position will "teleport" the object instantly. If you need to move it over time to that position, use MoveTo behavior.

  • Thank you guys.I understand how to teleport, touch aspects and movement with the moveto behaviour. I did not know that behaviour even existed until i inspected the behaviours thoroughly.

    I went through each behaviour and understood most of them and what they do by playing around. However could you guys explain to me what the difference between the timeline and path-finding behaviour is and what type of games they would suit or when they would be used?

    I played around with the timeline and created a small animation (keyframes) of enemy ai moving (max 5 seconds). However same can be done with the pathfinding right if you made a obstacle course on another layout? Which is better to use for Ai etc.

    Thank you for your help.

  • Timelines are mostly used for scripted sequences, to make cut-scenes, intros etc.

    Pathfinding is completely different. It finds a path around obstacles, can be used in many top-down view games (RPG, RTS, racing), certain puzzles etc. It's often an important part of creating an enemy AI.

  • Thank you I understand now.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)