Moving an Actor via Touch on screen

imperiousdevimperiousdev Member Posts: 35
edited November -1 in Working with GS (Mac)
Hi,

I have an actor in my game that I need to move depending on the users touch (user touches left side of screen, actor moves left, user touches right, actor moves right etc).

I have rules set up already which works for a keyboard arrow button and also the accelerometer But i cant seem to get the touch working.

I assumed it would be " Attribute game.Touches.Touch 1.X < -0.1 to make him go to the right.
But that doesnt seem to work.

Comments

  • GugsGamesGugsGames Member Posts: 54
    Probably not the most elegant solution and I'm sure others will have better advice, but when I was working on something with a similar control scheme, I simply created two invisible actors, one for the left side of screen, one for right, and then said if either were touched, the actor would move in the appropriate direction.
  • old_kipperold_kipper Member Posts: 1,420
    Above a perfectly good way of doing it. Worth adding rules to cancel control on both buttons being pressed, and if you are putting in scrolling put the buttons in a non scrolling layer so they stay with the camera.
  • orbnooborbnoob Member Posts: 79
    you could do what he did, or you could say if the x is less then 240, or whatever half the screen is, then move left, if its greater then 240, then move right
  • orbnooborbnoob Member Posts: 79
    have x be the position of the touch, there should already be an attribte called touch position i thin
  • imperiousdevimperiousdev Member Posts: 35
    Ah ok, thanks guys. A couple of ways to do it for me to consider there. I have the accelerometer control method implemented, just not sure if that is enough. I personally prefer games with touch controls.

    I shall have a play with the suggestions and get back if I fail ;)

    Thanks all
Sign In or Register to comment.