Step 5: Ground Detection/Gravity


Next, we will make the Enemy fall when there is no ground beneath it. On every frame, a fast loop will run 4 times. On each loop, if the Enemy is not overlapping an obstacle, it will be moved down 1 pixel.
Due to an bug in MMF2, we cannot start the loop during the same event that changes to the detector animation. We must create two separate Always events.
  • Always
  • : Start loop "Gravity" 4 times
Each loop moves the Enemy down 1 pixel and the loop runs 4 times every frame. This means that the Enemy will fall 4 pixels per frame.
8