Accelerometer Problem , Help needed !

marwanbarakatmarwanbarakat PRO Posts: 41
edited June 2012 in Working with GS (Mac)
Hi guys,
I'm making a portrait shooting game and im using the accelerometer to move the cursor. It looks like a game called High Noon
I'm using the following rules in the cursor prototype:
constrain attribute : self.motion.linear velocity.X To game.accelerometer.X * 800
constrain attribute : self.motion.linear velocity.Y To game.accelerometer.Y * 800

the 1st rule is 100% working as I need , but the 2nd is only working when the ( accelerometer Y ) has a positive value, that means the player has to make thier iphone in a flat (horizontal) state and tilt it down to play the game.

I tried to put a minus sign and tried to make a custom att. to change the accelerometer sign but it doesnt work.er

Please help me fixing this, or if there is any other way to do it.

Thanks

Answers

  • 95orange95orange PRO Posts: 18
    edited June 2012
    You want to use the absolute value... http://en.wikipedia.org/wiki/Absolute_value

    Constrain to abs(game.accelerometer.Y * 800)
  • kinzuakinzua Member Posts: 554
    @marwanbarakat consider caliberating the user sensor when he starts playing.. to do that.. create an attribute which reads the accel value Y on startup or when u think it wud b best.. Then use this value as ur 0 value and code accordingly....

    for eg.. u cud something like
    self.motion.linear velocity.Y To (game.startaccelValue-game.accelerometer.Y) * 800

    Not sure if that'll help.. Lemme know..
  • marwanbarakatmarwanbarakat PRO Posts: 41
    @kinzua i've tried that but its not working, its not even moving vertically
Sign In or Register to comment.