Can you turn off input?
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
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
-
MotherHoose Posts: 2,456
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"
MH
Answers
http://www.clay-communications.com/jamie/GS-slide.jpg
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.
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
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