Skip to main content
December 13, 2013
Question

How to make a vertical lift or elevator in a platform game

  • December 13, 2013
  • 1 reply
  • 3611 views

I am creating a side scrolling platform game using the book "Flash Game University" by Gary Rosenzweig.

My protagonist has an instance of "hero".


My current issue is trying to create a lift or elevator to carry the player up or down. The lift is not covered in the book. My thoughts were that the lift constantly moved up and down at a pace determined by a timer. I cannot get my lift to move. I have created a movie clip called "lift" and made it exported for action script. I can make it act similar to a floor movie clip so that I can stand on it, but I cannot get the lift to move on the y axis.


I tried creating a new function called lift() and using a for loop to count between 0 and 100 using a variable "i" and then make my lift move up 1 unit for each loopcycle. It didn't work.


lift.y -= lift.y - 1;


Does anyone have a better solution?


Thanks,

Alex

This topic has been closed for replies.

1 reply

Participating Frequently
December 13, 2013

you probably want to rename your lift function to some other name then your lift instance name and use onEnterFrame to to call your lift function at frame intervals.

December 13, 2013

I added the following code, but it still does not work.

                                        stage.addEventListener(Event.ENTER_FRAME,moveLifts);

public function moveLifts()

                              {

  this.lift.y -= 105;                 

}

Participating Frequently
December 13, 2013

lift.addEventListener(Event.ENTER_FRAME,moveLifts);

function moveLifts(e:Event)

{

          this.y -=  105;

}