Custom Touch Controls

Get help using Construct 2

Post » Sun Jul 14, 2013 7:12 pm

Hi.

I can't for the life of me figure out why this doesn't work.

http://www.darksunpictures/public/Touch_Movement.jpg

I'm trying to limit player movement, so it stays within my custom boundaries, so I don't have to use the default "Bound to Layout" behavior.

I was able to do this with custom keyboard controls, but having a bit of trouble with the touch controls.
B
27
S
15
G
10
Posts: 184
Reputation: 7,955

Post » Sun Jul 14, 2013 7:15 pm

Revised link that actually works:

Link
B
27
S
15
G
10
Posts: 184
Reputation: 7,955

Post » Mon Jul 15, 2013 8:33 am

could use link the capx aswell?

Think it would be easier to help you if we could run the code and try to understand where the problem is.
B
20
S
6
G
4
Posts: 347
Reputation: 4,451

Post » Mon Jul 15, 2013 5:31 pm

Sure.

1) Basically I'm trying to modify the existing template to do infinite scroll left and right; hence, I could not use the Bound to Layout or Bound by Edge behaviors for the Player sprite (I think).

I was able to make custom keyboard controls based on my defined window boundaries. I'll modify the left and right boundaries shortly to about 15% from each edge, as I would want the player to see where they are scrolling to (right now it just mimicks Bound by Edge).

2) I haven't yet gotten around to testing the scrolling left and right. Hopefully I can figure it out from the Space Blaster demo or some other code, but if someone has a tested solution that works, that'd be great.

3) The problem I ran into was with the touch controls. I was setting a boundary if/then condition to begin with, but that just stops the touch controls from working at the boundary, so I think the solution is permitted angles.

I would want infinite scroll left/right at the same speed for touch controls also (right now mimicked by left mouse click), so I think the permitted angle limitations would have to be set when player is right at my top boundary and bottom boundaries.

I did a code testing window, as you can see, to test how angles work in SC2, but I have no idea how to set it up, so I could use the code. I'm not finding the manual all that helpful as many functions I see in code examples are not defined? (not a criticism, just makes it harder).

I believe this is how angles work in SC2:

1) Top left quadrant is -90 to -180 (-180 same as 180?)
2) Top right quadrant is 0 to -90
3) Lower right quadrant 0 to 90
4) Lower left quadrant 90 to 180 (180 same as -180?)

So basically I think I would need this setup:

1) When Player sprite is at the top boundary, permitted movement angles for touch controls are only lower left and right angle quadrants (0 to 180)

2) When Player sprite is at the bottom boundary, permitted movement angles for touch controls are only top left and right angle quadrants (0 to -180)

If there's an easier way, that'd be great, but I think in theory this should work.

The problem with setting up custom boundary limitations on touch controls I ran into initially was that the system conditions checking for Player.X for example in between two values (left and right boundaries) just did not work at all with the touch formula (no idea why as the logic seems sounds, but maybe they're not programmed to work with that code).

One other weird thing I ran into. A global variable named AllowTouchControls as a flag made the code unstable, so I deleted thinking it was already some system variable. If true, it would be helpful to know others, so we don't inadvertently make unstable code.

Here is the link to the capx:


CapX
B
27
S
15
G
10
Posts: 184
Reputation: 7,955

Post » Tue Jul 16, 2013 5:52 am

Never mind figured it out today (no angles needed).

Just gotta work on the scroll.
B
27
S
15
G
10
Posts: 184
Reputation: 7,955


Return to How do I....?

Who is online

Users browsing this forum: DaniellMesquito, PauloMarcio, repkino, SnipG and 4 guests