Need help with dodge controls

Pennez-GamesPennez-Games Member Posts: 107
edited July 2012 in Working with GS (Mac)
ok so im making a dodge type game, with touch screen controlls,
so iv got two controlls, left and right,
ok so heres the problem, when i click the right controll the actor moves right, but if i want to click right again, the actor wont move right, you have to click the left control before being able to use the right control again howcome? i dont know why, its realy confusing, help would be very appreciated! thanks

Comments

  • stackpoolestackpoole Melbourne, Victoria, AustraliaMember, PRO Posts: 473
    Hi,

    I think if you post or show us a screenshot of your rules that trigger the controls, we may be able to help!

    Sydney Swans 2014!!

  • MotherHooseMotherHoose Member Posts: 2,456
    tapping your right button … changes a gameAttribute
    that gameAttribute trigger the actor's rule for movement

    tapping that button again does nothing
    because the gameAttribute has already been changed
    and the movingActor's rule has already run
    ==

    you need to reset that gameAttribute:
    in the button's rule add changeAttribute Behavior in the Otherwise: section

    EX: for boolean gameAttribute
    Rule: when
    Event: touch is pressed
    -changeAttribute: game.Right To: true
    Otherwise:
    -changeAttribute: game.Right To: false

    but for a moving actor that has 3 states … standstill; right; left
    only one gameAttribute … index type … name: Direction … is needed
    0 = standstill
    1 = move right
    2 = move left

    then on your rightButton actor
    Rule: when
    Event: touch is pressed
    -changeAttribute: game.Direction To: 1
    Otherwise:
    -changeAttribute: game.Direction To: 0

    and on your movingActor:
    Rule: when
    Attribute: game.Direction = 1
    -do this
    Otherwise:
    Rule: when
    Attribute: game.Direction = 2
    -do that

    add Rule: when
    Event: overlaps or collides with your walls
    -changeAttribute: game.Direction To: 0

    image MH
  • Pennez-GamesPennez-Games Member Posts: 107
    tapping your right button … changes a gameAttribute
    that gameAttribute trigger the actor's rule for movement

    tapping that button again does nothing
    because the gameAttribute has already been changed
    and the movingActor's rule has already run
    ==

    you need to reset that gameAttribute:
    in the button's rule add changeAttribute Behavior in the Otherwise: section

    EX: for boolean gameAttribute
    Rule: when
    Event: touch is pressed
    -changeAttribute: game.Right To: true
    Otherwise:
    -changeAttribute: game.Right To: false

    but for a moving actor that has 3 states … standstill; right; left
    only one gameAttribute … index type … name: Direction … is needed
    0 = standstill
    1 = move right
    2 = move left

    then on your rightButton actor
    Rule: when
    Event: touch is pressed
    -changeAttribute: game.Direction To: 1
    Otherwise:
    -changeAttribute: game.Direction To: 0

    and on your movingActor:
    Rule: when
    Attribute: game.Direction = 1
    -do this
    Otherwise:
    Rule: when
    Attribute: game.Direction = 2
    -do that

    add Rule: when
    Event: overlaps or collides with your walls
    -changeAttribute: game.Direction To: 0

    image MH

    thanks so much!! you totally fixed my problem! thanks!!
  • Pennez-GamesPennez-Games Member Posts: 107
    For future reference, please don't open threads with vague titles like, "Help here please!" Be more specific.

    Changed the title accordingly.


    sorry
Sign In or Register to comment.