Camera

Cam

package com.camera{
    import flash.events.Event;
    import flash.display.MovieClip;
    import com.globals;
    import com.globalFunctions;
    public class Cam extends MovieClip{
        private var roof:MovieClip;
        public function Cam():void {
            roof=new camRoof();
            roof.visible=false;
            globals.levelObj.ground.addChild(roof);
            addEventListener(Event.ENTER_FRAME, camMovement, false, 0, true);
        }
        private function camMovement(e:Event):void {
            x+=globals.camSpeed;
            y-=(y-(globalFunctions.getY(globals.hero)-globals.levelObj.y)/2)/5;
            roof.x=globalFunctions.makeX(roof, x);
            roof.y=globalFunctions.makeY(roof, y)-globals.gameHeight/2;
            globals.main.y=-y+globals.gameHeight/2;
            globals.main.x=-x+globals.gameWidth/2;
        }
    }
}
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License