0 Replies Latest reply on Jul 13, 2011 8:53 PM by onilink422

    I need help with Gravity

    onilink422

      Before any one asks, I have scoured the internet for quite awhile in search of the answer to what I need, but no luck. I have found scripts that look promising, but end up giving me an error code, and I am not fluent enough with actionscript to find out how to fix it.

      Any way, back to my original point, I am making a Platformer Flash game where my main character (Char) needs to interact with such obsticles as a ground.

      I need a simple way to intoduce Gravity as well as jumping. The game I am developing is an AIR for iOS file, so it is used with an Acceporometer for movement. I have an on screen Button that is a clickable button, and I would like to use it for the jumping.

      This is a sample of my code...

      *********************

      /* Move with Accelerometer Allows the object to be moved by tilting the mobile device.  Instructions: 1. To increase or decrease the amount of movement, replace the number 30 below with the number of pixels you want the symbol instance to move when tilting the mobile device. Note the number 30 appears twice in the code below. */  var fl_Accelerometer_3:Accelerometer = new Accelerometer(); fl_Accelerometer_3.addEventListener(AccelerometerEvent.UPDATE, fl_AccelerometerUpdateHandler_3);  function fl_AccelerometerUpdateHandler_3(event:AccelerometerEvent):void {      levelone.x+= event.accelerationX*30;            }  /* Flip with Accelerometer Allows the object to flip by tilting the mobile device.  Instructions: 1. To increase or decrease the amount of movement, replace the number 30 below with the number of pixels you want the symbol instance to move when tilting the mobile device. Note the number 30 appears twice in the code below. */  var fl_Accelerometer_5:Accelerometer = new Accelerometer(); fl_Accelerometer_5.addEventListener(AccelerometerEvent.UPDATE, fl_AccelerometerUpdateHandler_5);  function fl_AccelerometerUpdateHandler_5(event:AccelerometerEvent):void {      if(event.accelerationX>0){       movieClip_20.scaleX=-1  } else if(event.accelerationX<0){       movieClip_20.scaleX=+1  } }

      **********************

      I appologize for the crude formatting with the code.

      Screen shot:

      Example.png