GameSalad

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Make actor move one direction at a time.

rickynikorickyniko Posts: 85Member
edited November -1 in Working with GS (Mac)
Hello, im in the process of making a game, and the actor is controlled by a virtual dpad.
i was wondering how to make it so the actor can only move 1 direction at a time

so Up, THEN down etc etc.

i dont want the player to have the abilty to press down up/left at the same time and have the actor traveling on an angle.
know what i mean?

Comments

  • POLYGAMePOLYGAMe Posts: 3,470Member
    Hehe, I wanted the diagonals... very hard to get them unless you make the d-pad buttons HUGE. You should be okay ;)
  • rickynikorickyniko Posts: 85Member
    thanks for the response POLYGAMe,
    so your the one that made PRANKSTAR, ahahaa, that one scared the heck out of my 10 year old sister ahahha :P good one
  • BarkBarkCoBarkBarkCo Posts: 1,400Member
    Shouldn't be hard...

    I'm thinking the math will look something like this:

    `ceil(((VectorToAngle(joyCenter.x - joyTouch.x, joyCenter.y - joyTouch.y)-22.5)%360)/45)*45`

    The order of "joyCenter" and "joyTouch" may need to be reversed in the VectorToAngle function. I'll test it on my lunch break...
  • POLYGAMePOLYGAMe Posts: 3,470Member
    rickyniko said:
    thanks for the response POLYGAMe,
    so your the one that made PRANKSTAR, ahahaa, that one scared the heck out of my 10 year old sister ahahha :P good one

    Haha, hope she didn't drop your iPhone ;)
  • rickynikorickyniko Posts: 85Member
    POLYGAMe said:
    Haha, hope she didn't drop your iPhone ;)

    haha, nah she threw it on the couch hahah
  • rickynikorickyniko Posts: 85Member
    barkbark00 said:
    Shouldn't be hard...

    I'm thinking the math will look something like this:

    `ceil(((VectorToAngle(joyCenter.x - joyTouch.x, joyCenter.y - joyTouch.y)-22.5)%360)/45)*45`

    The order of "joyCenter" and "joyTouch" may need to be reversed in the VectorToAngle function. I'll test it on my lunch break...

    thanks for that, ill try it out soon!

    by the way, if you can, try help out with my other topic, its really recent so it should be up there)
  • BarkBarkCoBarkBarkCo Posts: 1,400Member
    I'll actually have to open GS to work that one out...maybe later.
This discussion has been closed.