on Touch Controls

Get help using Construct 2

Post » Wed Dec 05, 2012 4:12 pm

Hi,

Can anyone tell me how to do this:
When I drag the sprite using touch control, the movement of the sprite must only go up and down in one place.

thanks in advance.
B
4
Posts: 20
Reputation: 390

Post » Wed Dec 05, 2012 4:38 pm

Yeah. I found using the Drag and Drop behaviour works poorly when your trying to use it with setPosition() when limiting area.

I have a thought on how you can do this

Don't Drag and Drop your slider icon.
Create an invisible drag and drop object over your up/down slider sprite.
set Y position of your slider to the Y of your Drag Box.

This will limit your slider sprite to the Y axis.
You will also need to check for Y minimum and maximum ranges. You can do this with a heavy inline if statement or 2 extra sub events.

slider.y = ( (drag.y < min) || (drag.y > max) ? (drag.y < min ? min : max) : drag.y )

don't forget to reset your drag box on drop :)

here is a tutorial. Overkill for you needs but you never know what helpful information you can find.
http://www.scirra.com/tutorials/398/touch-stick-controllers/page-1

Now if there is a way to limit an particular objects axis. That would be cool, but I have no idea if that exists. Still a noob here :D
B
87
S
18
G
9
Posts: 2,455
Reputation: 14,834

Post » Wed Dec 05, 2012 5:18 pm

Thanks man! This was very helpful!

Keep it up!
B
4
Posts: 20
Reputation: 390

Post » Wed Dec 05, 2012 5:36 pm

Actually thinking about it while walking my son to school I had another thought.

If your using the controls for some kind of main menu or options(ie volume control). Then you don't need to prepare for multi touch input. Instead you can make it a little easier.

Here is a sample of all 3 ways I suggested.
https://dl.dropbox.com/u/14087254/lineardragsprite.capx
B
87
S
18
G
9
Posts: 2,455
Reputation: 14,834

Post » Thu Dec 06, 2012 1:07 am

Hi again,

I have a Problem...
The Sprites moves in Circles, I think it's because of radius.
How am I going to make it move not in radius but all in a square sprite (don't know the terms yet)

B
4
Posts: 20
Reputation: 390

Post » Thu Dec 06, 2012 5:40 pm

I think reading the purpose of the tutorial would help, however I also linked a capx that will serve your purpose for linear sliding of a touch event. the linking of the tutorial was only for checking out how to do drag and drop object to effect another sprite. not to literally copy command for command :D

However, I thought of an easiest way to do only up and down sliding. I updated the capx.

here is the link to the capx samples directly relating to what you want
https://dl.dropbox.com/u/14087254/lineardragsprite.capx


there are 3 models.
Left: uses ontouch background object
middle: drag and drop the slider box
right: drag and drop a drag box that effects the moving sprite.

choose one that serves you best :)
B
87
S
18
G
9
Posts: 2,455
Reputation: 14,834

Post » Thu Dec 06, 2012 10:48 pm

Thanks again man!
It really worked fine!

B
4
Posts: 20
Reputation: 390


Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go, abdalghani, imothep85, jeffige, Marxally, Virpoja and 25 guests