How do I move an object acording to touch?

0 favourites
  • 15 posts
From the Asset Store
This is a single chapter from the "Construct Starter Kit Collection". It is the Student Workbook for its Workshop.
  • I am making a shoot them up and need to move the ship like the dodonpachi ressurection and other shmup games.

    basically, you're supposed to touch anywhere on screen and then move your finger while still touching. the sprite needs to imedeately move the same amount of pixels as the finger.

    I really need this help,tx.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • this video ilustrates better what I want. anyone know how I cana chieve this in construct2?

    youtube.com/watch

  • can you find the x position where you first touch the screen ? (and store this position maybe in a instance variable ?)

    do something like while in touch find new touch x position (store this position)

    find the difference between old touch x and new touch x position

    offset your ship by same amount

    set old touch to be the new touch

    do it again while in touch

  • looks like simple drag and drop behaviour with offset.

    either create a sprite on touch with drag and drop and pin it to the ship position sprite, or create offsetx and offsety variables and position the ship acording to touch.x-offsetx and touch.y-offsety.

  • looks like simple drag and drop behaviour with offset.

    either create a sprite on touch with drag and drop and pin it to the ship position sprite, or create offsetx and offsety variables and position the ship acording to touch.x-offsetx and touch.y-offsety.

    would drag and drop really work? doesn't drag and drop involve directly touching the sprite? I need to move it regardless of the touch point.

    about these offsets variables, should they be global variables?

  • if you create a sprite at touch.x,touch.y with drag and drop behaviour, pin the ship to it and on touch end destroy the sprite.. should work..

  • if you create a sprite at touch.x,touch.y with drag and drop behaviour, pin the ship to it and on touch end destroy the sprite.. should work..

    I think I understand it now, thanks a lot. this pinning thing, is it an event action like this: ship -> position -> set position acording to this touch.x, touch.y object?

  • I was actually thinking of using pin-behaviour for it..

    You could also do the offset way, it's just preference..

  • I was actually thinking of using pin-behaviour for it..

    You could also do the offset way, it's just preference..

    I didn't know about the pin behaviour existence :p

  • move with touch example

    <img src="https://dl.dropboxusercontent.com/u/143636437/examples%20for%20web/Ashampoo_Snap_2014.02.05_22h08m05s_002.png" border="0">

  • move with touch example

    <img src="https://dl.dropboxusercontent.com/u/143636437/examples%20for%20web/Ashampoo_Snap_2014.02.05_22h08m05s_002.png" border="0">

    looks simple enough, I'll try it.

  • looks like simple drag and drop behaviour with offset.

    either create a sprite on touch with drag and drop and pin it to the ship position sprite, or create offsetx and offsety variables and position the ship acording to touch.x-offsetx and touch.y-offsety.

    I'm sucessfully pinning objects now, but once an object gets pinned, it looses it's "bound to layout" property. is there a way to fix it?

  • > move with touch example

    >

    > <img src="https://dl.dropboxusercontent.com/u/143636437/examples%20for%20web/Ashampoo_Snap_2014.02.05_22h08m05s_002.png" border="0">

    looks simple enough, I'll try it.

    It doesn't work. since the variables are the same, the sprite doesn't move.

  • Sorry - I missed this.

    Of course it works - didn't you download the capx ?

    demo

  • RamPackWobble> move with touch example

    <img src="https://dl.dropboxusercontent.com/u/143636437/examples%20for%20web/Ashampoo_Snap_2014.02.05_22h08m05s_002.png" border="0">

    Hey,

    Unable to find the capx file.

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