Need help with making proper onscreen controls

Pennez-GamesPennez-Games Member Posts: 107
edited July 2012 in Working with GS (Mac)
for ages now iv been trying to make on screen controlls, it never works!! please help, i am trying to do this
you have two onscreen controlls, right and left, you hold down left and the actor on the screen moves left, but you have to hold it down to move the actor, please can anyone help me?

Comments

  • HapiappsHapiapps Member Posts: 373
    Make an attribute thats an integer, call it direction (or whatever you like).

    In the left button:
    When touch is pressed, change attribute direction to 1
    Otherwise, change attribute direction to 0

    In the right button:
    When touch is pressed, change attribute direction to 2
    Otherwise, change attribute direction to 0

    In the object that moves left or right:
    If attribute direction = 1 move left
    If attribute direction = 2 move right

  • Pennez-GamesPennez-Games Member Posts: 107
    Make an attribute thats an integer, call it direction (or whatever you like).

    In the left button:
    When touch is pressed, change attribute direction to 1
    Otherwise, change attribute direction to 0

    In the right button:
    When touch is pressed, change attribute direction to 2
    Otherwise, change attribute direction to 0

    In the object that moves left or right:
    If attribute direction = 1 move left
    If attribute direction = 2 move right


    i did this, but when i click it or hold the arrow key down, the character will move like half an inch then stop, i click again same thing?
  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    Not sure what you want, you say you need to hold it down but that's how a button works you hold it down for the player to move left and let go to stop and then hold down right to move and then let go to stop. Those are NORMAL controls so you need to explain how you want yours to work..we don't read minds..lol
  • Pennez-GamesPennez-Games Member Posts: 107
    Not sure what you want, you say you need to hold it down but that's how a button works you hold it down for the player to move left and let go to stop and then hold down right to move and then let go to stop. Those are NORMAL controls so you need to explain how you want yours to work..we don't read minds..lol
    that is what i want how can i do this?
  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    Click on the gsguide link in my signature then go to templates and download the jump controls template.
  • PBEmpirePBEmpire Member Posts: 676
    Create attribute called move . Let it be an integer attribute. Create a left button and a right button. In your buttons, create rle- when touch is pressed inside, change attribute move to 1. When touch is released, change attribute to 0. Then in your actor, create rule when attribute move is 1, move in x direction at x speed. When attribute is 0, stop moving.
    Hope that helps! In my game, I did that and it works.
    Hey! Can u ell me out with my problem? http://forums.gamesalad.com/discussion/47173/ball-problem#latest
  • Pennez-GamesPennez-Games Member Posts: 107
    edited July 2012
    Click on the gsguide link in my signature then go to
    templates and download the jump controls template.

    i did that,. except i want onscreen controlls, not pc keyboard controlls.
  • Pennez-GamesPennez-Games Member Posts: 107
    edited July 2012
    Create attribute called move . Let it be an integer attribute. Create a left button and a right button. In your buttons, create rle- when touch is pressed inside, change attribute move to 1. When touch is released, change attribute to 0. Then in your actor, create rule when attribute move is 1, move in x direction at x speed. When attribute is 0, stop moving.
    Hope that helps! In my game, I did that and it works.
    Hey! Can u ell me out with my problem? http://forums.gamesalad.com/discussion/47173/ball-problem#latest

    wait, it worked!!! thanks man so much, ill have a look at your problem now ;D
  • schwarzAschwarzA Member Posts: 4
    @soundwaveninja

    This is the easiest way (for me) to have left and right controls...

    Make 3 blank actors and name them this:
    Player
    Left
    Right
    (put a color or display text for the left and right actors, this way you can determine which is which)

    Then make 2 game attributes (these will both be integer attributes)
    Name them:
    MoveLeft
    MoveRight
    (leave them at 0)

    Then go into your Player actor...
    Create 2 Rules

    In your first rule do:
    When attribute game.MoveLeft = 1
    (Drag in your Move behavior)
    Move -
    Direction 180 (180 is left)
    Relative to actor

    Second Rule:
    When attribute game.MoveRight = 1
    Move -
    Direction 0 (0 is right)
    Relative to actor

    Your player actor is finished!


    Now for your controls.

    Go into your Left actor
    Create 2 rules

    First Rule:
    When touch is pressed
    Change attribute -
    game.MoveLeft = 1

    Second Rule:
    When touch is released
    Change attribute -
    game.MoveLeft = 0

    Your left actor is finished!

    Go into your Right actor
    Create 2 rules

    First Rule
    When touch is pressed
    Change attribute -
    game.MoveRight = 1

    Second Rule:
    When touch is released
    Change attribute -
    game.MoveRight = 0

    YOUR FINISHED!!

    Now hit preview... you will see your left and right actors will move your "player" left when held down... when you let go of the left button the player will stop... When you hold down right, your player will move right.

    Hope this helps you!
  • Pennez-GamesPennez-Games Member Posts: 107
    @soundwaveninja

    This is the easiest way (for me) to have left and right controls...

    Make 3 blank actors and name them this:
    Player
    Left
    Right
    (put a color or display text for the left and right actors, this way you can determine which is which)

    Then make 2 game attributes (these will both be integer attributes)
    Name them:
    MoveLeft
    MoveRight
    (leave them at 0)

    Then go into your Player actor...
    Create 2 Rules

    In your first rule do:
    When attribute game.MoveLeft = 1
    (Drag in your Move behavior)
    Move -
    Direction 180 (180 is left)
    Relative to actor

    Second Rule:
    When attribute game.MoveRight = 1
    Move -
    Direction 0 (0 is right)
    Relative to actor

    Your player actor is finished!


    Now for your controls.

    Go into your Left actor
    Create 2 rules

    First Rule:
    When touch is pressed
    Change attribute -
    game.MoveLeft = 1

    Second Rule:
    When touch is released
    Change attribute -
    game.MoveLeft = 0

    Your left actor is finished!

    Go into your Right actor
    Create 2 rules

    First Rule
    When touch is pressed
    Change attribute -
    game.MoveRight = 1

    Second Rule:
    When touch is released
    Change attribute -
    game.MoveRight = 0

    YOUR FINISHED!!

    Now hit preview... you will see your left and right actors will move your "player" left when held down... when you let go of the left button the player will stop... When you hold down right, your player will move right.

    Hope this helps you!


    thanks for your help, this does work aswell as what gsroxs told me, thanks!
Sign In or Register to comment.