Shaking your phone

matthewadavidmatthewadavid Member Posts: 26
edited November -1 in Working with GS (Mac)
Can you set up an Action to happen when you shake your phone?

Comments

  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    As long as you are not making another shake the baby app. :p

    Use the accelerometer behavior, a few of boolean attributes, and a few of Timer, Rules, and Change Attribute behaviors.

    Rule 1: If game.Accelerometer.Y > .5
    --Change Attribute: game.ShookLeft = true
    --Timer: After .4 seconds, run to completion
    ----Change Attribute: game.ShookLeft = false

    Rule 2: If game.Accelerometer.Y < -.5
    --Change Attribute: game.ShookRight = true
    --Timer: After .4 seconds, run to completion
    ----Change Attribute: game.ShookRight = false

    Rule 3: If game.ShookLeft is true AND game.ShookRight is true
    --Congrats you have shaken the device.
  • matthewadavidmatthewadavid Member Posts: 26
    Ahh, no. Maybe another "More Cow Bell" ;)
  • HunnenkoenigHunnenkoenig Member Posts: 1,173
    Is this still accurate? Or is there any new feature/solution I can use?

    I want to make a feature that when you shake your phone, the ball gets another direction, because sometimes it sticks between 2 walls in 90° ping-pong and you can't finish the game because of this.
  • POMPOM Member Posts: 2,599
    a great way! thank you codemonkey for sharing this info with us.
    how would you suggest to do the same thing with the same result, but to check if it works with the mouse or the keyboard?
  • StormyStudioStormyStudio United KingdomMember Posts: 3,989
    on the keyboard have a button that makes the shake attribute true,

    or test on your device using gs viewer
  • HunnenkoenigHunnenkoenig Member Posts: 1,173
    On the keyboard works great.
    I have to test it on the iPhone yet.

    Thanks for the tutorial anyway! :-)
Sign In or Register to comment.