Need Some help with touch controls

Get help using Construct 2

Post » Sun Feb 19, 2017 2:13 pm

Hi guys,

I have started working on a new game although i have been working on construct 2 from a time but am struggling with one thing....am just not able to get the perfect result..

So here it is...through touch controls i want my player to move left and right...when user touch and move finger from right to left the player should move and get "mirrored" and when user touch move finger from left to right player should move and get "not mirrored"...i have implemented it...but not working that good..

So whats happening...player is moving fine...but not getting mirrored and not mirrored on time...sometime it does sometimes i have to drag more to make it mirrored....i need to make smooth need result kinda similiar to this game challenge 1
https:// play .google .com/store/ apps/details?id =com .dotgears .ninjabounce

Right now touch works in bottom in my game but if i would be able to make it smooth i wanted to implement for full screen touch

Here is the capx am working on
https:// www. dropbox. com/s/ rtdy2dl5e67smri/touch. capx? dl=0

Sorry had to add space between links not have enough reput

Thanks
B
6
S
1
Posts: 52
Reputation: 500

Post » Sun Feb 19, 2017 5:49 pm

Forum is full of examples.
https://www.google.be/search?q=scirra+m ... scirra.com


But lets do it the most basic of basic ways for you:
https://www.dropbox.com/s/qvzjnxq4vaqfh ... .capx?dl=0
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Sun Feb 19, 2017 6:02 pm

99Instances2Go wrote:But lets do it the most basic of basic ways for you:
https://www.dropbox.com/s/qvzjnxq4vaqfh ... .capx?dl=0


THAT Filename. :lol: :lol: :lol:
Image Image Image
B
29
S
11
G
27
Posts: 730
Reputation: 17,002

Post » Sun Feb 19, 2017 6:20 pm

shush !
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Sun Feb 19, 2017 6:47 pm

Sounds like you need a center point on the X axis to check when dragging.

Global Variable CenterX

Set that to the center of the layout.

On Sprite X < CenterX Mirror Sprite

On Sprite X > CenterX set sprite Default animation

If you want it to switch every time you swipe left or right then set Center X at the X position of your sprite using every tick and use a global variable called OldX for the last X position of the sprite.

OldX = CenterX
CenterX = Sprite X

On CenterX < OldX Mirror Sprite
On CenterX > OldX Set Sprite animation Default
Banned User
B
27
S
7
G
58
Posts: 1,229
Reputation: 34,790

Post » Mon Feb 20, 2017 6:46 am

@99Instances2Go
Thanks brother sometimes one needs embarrassment to get motivation..thanx a lot for the help...btw you got nice sense of humour :P :P

@lamar
thanks for the reply :)
B
6
S
1
Posts: 52
Reputation: 500

Post » Mon Feb 20, 2017 8:35 am

@aashcool07

Do you see the basic mechanic ?
To be read as ....
"
... calculate relative difference between current touch and previous touch ...
add relative difference to object that you wanna move ...
... make current touch the previous touch ...

"

You going to need this a lot in a lot of situations. That translate 'absolute to relative'.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Tue Feb 21, 2017 9:48 am

@99Instances2Go
Yeah i saw that still trying to figure out...understood lil bit trying hard to learn...actually am not from coding background but have to learn this...

Thanks by the way :)
B
6
S
1
Posts: 52
Reputation: 500


Return to How do I....?

Who is online

Users browsing this forum: David181, evillair and 56 guests