Custom Touch Controls

0 favourites
  • 5 posts
From the Asset Store
Surena Touch
$2.50 USD
A wrap from official Touch plugin to export touch/mouse input to other plugins.
  • 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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Revised link that actually works:

    Link

  • 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.

  • 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

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

    Just gotta work on the scroll.

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