Can you turn off input?

jamie_cjamie_c ImagineLabs.rocksMember, PRO Posts: 5,772
edited May 2012 in Working with GS (Mac)
In my game when my player touches a slope, he slides down the slope and I want to turn off all input so you can't slow your slide down, jump from the slope, etc.

I tried making an attribute called 'playerSlidingLeft' and set it to true if the player is touching the slope. In my control I check to see if the attribute 'playerSlidingLeft' is false, if it is the control is checked for input. It almost works but the problem is when you first get onto the slope by holding down the control you can keep the control down and repeating I guess. If I let the control go and then re-apply it, it is not working (as it should be since you are sliding). But I need to shut the control off immediately once the slope is identified, so the held down control would be cut off too.

Can this be done?

thanks
Jamie

Best Answer

  • MotherHooseMotherHoose Posts: 2,456
    Accepted Answer
    IMO the gameAttribute should be named onSlope

    on your playerActor:
    Rule: when
    Event: overlaps or collides with actor with tag slope
    -changeAttribute: game.onSlope To: true
    -other changes such as image; rotation; increasedAcceleration; etc.
    Otherwise:
    -changeAttribute: game.onSlope To: false
    -other changes such as image; rotation; increasedAcceleration; etc.

    on buttons:
    Rule: when (All)
    Event: touch is pressed
    Attribute: game.onSlope is: false
    -do this or that

    if this is a skiJump then you will need invisible sensorActors to define the active parts of the slopeImage … assign those sensors the tag "slope"

    image MH

Answers

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Can you post a screenshot of your rules? It shouldn't be doing that.
  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772
    Sure, the screen grab can be seen here:

    http://www.clay-communications.com/jamie/GS-slide.jpg
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    I think what's happening is that because game.playerSlidingLeft is initially false, when the player presses the Left button, the inner rule checks the condition to see if Touch is Pressed and when it is pressed, it changes game.Left to true. The Otherwise behavior doesn't ever occur because as soon as game.playerSlidingLeft changes to true (upon collision), that whole rule stops processing.

    One thing I tried was moving the "Change attribute game.Left to false" behavior to the Otherwise section of the outer rule (When game.playerSlidingLeft is false). That had the effect of preventing continued holding of the Left button, but in my sample game it also stopped the gravity on the moving actor. Give it a try and see if it helps.
  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772
    Hi Tatiang,

    I followed your advice and got some interesting results. In my game I set up an onscreen display of my game.left attribute so I could keep and eye on it and using the touch control (with your suggestion) it shows false, true, false, true, etc. if I continue to hold the 'left' button down once I'm on the slope. However if I release the left button completely and try to re-apply it the display stays at false and the slope works as it should.

    Here's the real kicker, I set up a keyboard control to test that and it works perfectly. When holding the left arrow and touching a slope the on screen display immediately reads false and the slope works as expected.

    I hope maybe it's just an 'ipad emulation thing' and if I run it on my ipad it will work fine with the touch controls. That will be my next test.

    Below are screen shots of the two controls for your reference.

    http://www.clay-communications.com/jamie/touch.jpg

    http://www.clay-communications.com/jamie/keyboard.jpg

    Jamie
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    @jamie_c I'm not really sure why it's not working. Your rules look the same, so I would expect them to do the same thing.
  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772
    edited May 2012
    MotherHoose, that worked perfectly! Thanks so much to both of you for all your help I really appreciate it!

    Just fyi, in my previous attempt I had the slope checking to see if the player was on it, but now I've moved that check onto the player like you mention above. That is what seemed to make the difference.

    Jamie
Sign In or Register to comment.