How do I create a direct relationship between touch and mouse events so that I don't have to modify

  • How do I create a direct relationship between touch and mouse events so that I don't have to modify hundreds of touch conditions.

    For example, here's what I would imagine would be the simplest best way of doing it.

    single touch = mouse hover

    double touch = mouse left click

    I have hundreds of instances of "Mouse" in my code and I'm sure I could modify each condition to have an "OR" something like if mouse click OR touch, cursor over button or touch coordinates over button etc.. but that would really suck having to program all that in and would bloat my code and be very tedious. My game has many buttons, hover events, and tons of actual pieces to interact with so there are a lot of events that require either clicking or hovering. I don't have any right clicks.

    Does anyone have any recommendations? Preferably a couple events I could put in at the start of layout? I couldn't find anything online about this.

    Thanks

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Here is what I would probably do:

    dropbox.com/s/56j5rby2vg591lj/MouseAndTouchToFunctions.c3p

    You add all clickable/touchable objects to families. And replace all "On touched", "On object clicked" etc. events with functions. Map these functions, so you could call them by name. (this may be easier to do with the old Function plugin)

    Of course, this is a very basic example. You can add more things, for example create two global variables MouseTouchX and MouseTouchY. Add an event at the top of your event sheet which will set these variables to either touch or mouse x|y coordinates, whichever is active. And in all other events use these variables.

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