我的游戏滞后,当我preSS按钮 [英] My game lags when I press button

查看:122
本文介绍了我的游戏滞后,当我preSS按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我开发iOS和Android使用AS3的应用程序。我目前有这个项目的一些性能问题。这是我的第一个应用程序及游戏。因此,任何类型的反馈或洞察力大大AP preciated。我的游戏是一个越野车车轮离地游戏。它允许用户PSS的按钮(气体preSS)$ P $到车轮离地向上和另一个按钮(制动),以向下车轮离。一旦气preSS按钮pssed $ P $,一个布尔holdGas设置为true。在我的gameLoop(ENTER_FRAME事件),自行车向上旋转,IFholdGas等于为true。在code为pressing制动是一样的,只不过它旋转自行车donward。我有一个在屏幕上滑动的建筑,创造了错觉,以为自行车是感动。该建筑影片剪辑缓存为位图。我用的是同一栋大楼影片剪辑的两个实例。一旦第一个剪辑滑出阶段,它被放置落后于其他。在回收一种机制笑。我在这里的问题是,当我preSS气preSS按钮,车轮离地前,滞后/旋转向上。当它滞后,建筑物移动在后台跳过。它发生的每一次。所以,如果你继续攻燃气preSS,(这是游戏的一部分)在屏幕上的对象保持跳跃。这使得游戏无法播放。我已经被完全删除code键移动自行车向上/向下测试按钮和游戏还是跳过。我发现更多的是跳跃的或落后时,气是pressed和自行车向上旋转。我现在有帧速率设置为32,它也做了同样的24。

 公共职能TheGame(){
            //连接到tapjoy的广告网络
            // tjClass =新TapJoyClass();
            //stage.scaleMode = StageScaleMode.NO_SCALE时;
            //stage.align = StageAlign.TOP_LEFT;
            //给比赛焦点,使键盘的按键将工作电脑
            stage.focus =这一点;
            globalStage = this.stage;
            //检查是否ScoreData和自行车数据的共享对象已经创建,如果没有它创建
            scoreInfo = SharedObject.getLocal的(ScoreData);
            bikeInfo = SharedObject.getLocal的(BikeData);
            //scoreInfo.clear();
            //bikeInfo.clear();
            mostSprocketsCollected = scoreInfo.data.mostSprocketsCollected;
            //处理背景
            background1 =新的背景;
            background2 =新的背景;
            的addChild(background1);
            的addChild(background2);
            background1.cacheAsBitmap = TRUE;
            background2.cacheAsBitmap = TRUE;
            background1.mouseChildren = FALSE;
            background1.mouseEnabled = FALSE;
            background2.mouseChildren = FALSE;
            background2.mouseEnabled = FALSE;
            background1.x = background1.width;
            background2.x = background1.x + background2.width;
            //处理建筑
            building1 =新建筑;
            building2 =新建筑;
            的addChild(building1);
            的addChild(building2);
            building1.cacheAsBitmap = TRUE;
            building2.cacheAsBitmap = TRUE;
            building1.mouseChildren = FALSE;
            building1.mouseEnabled = FALSE;
            building2.mouseChildren = FALSE;
            building2.mouseEnabled = FALSE;
            building1.x = building1.width;
            building2.x = building1.x + building2.width;
            //选择其中的自行车将被使用
            如果(bikeInfo.data.EquippedBike ==未定义){
                //与原来的自行车刚开始时
                whichBike =OriginalDirtBike;
                bikeInfo.data.BikeColor =OriginalDirtBike;
            }其他{
                whichBike = bikeInfo.data.EquippedBike;
            }
            如果(whichBike ==女妖){
                //添加远轮第一
                wheelClip2 =新Banshee_Far_WheelClip;
                的addChild(wheelClip2);
                // wheelClip2。 = 208.30;
                wheelClip2.y = 350;
                //添加女妖
                bitmapBike =新Banshee_Bitmap();
                bitmapBike.gotoAndStop(bikeInfo.data.BikeColor);
                的addChild(bitmapBike);
                bitmapBike.y = 399.80;
                bitmapBike.x = 0;
                //添加frontWheels
                wheelClip =新Banshee_WheelClip();
                wheelClip.backTire.frontFace.gotoAndStop(bikeInfo.data.BikeColor);
                wheelClip.frontTire.frontFace.gotoAndStop(bikeInfo.data.BikeColor);
                的addChild(wheelClip);
                wheelClip.x = 187.70;
                wheelClip.y = 399;
            }否则,如果(whichBike ==SupermotoDRZ400){
                //添加车轮
                wheelClip =新WheelClip();
                wheelClip.backTire.gotoAndStop(bikeInfo.data.BikeColor);
                wheelClip.frontTire.gotoAndStop(bikeInfo.data.BikeColor);
                的addChild(wheelClip);
                wheelClip.x = 0;
                wheelClip.y = 409.45;
                //添加自行车
                bitmapBike =新SuperMoto_Bitmap();
                bitmapBike.gotoAndStop(bikeInfo.data.BikeColor);
                的addChild(bitmapBike);
                bitmapBike.y = 399.80;
            }否则,如果(whichBike ==OriginalDirtBike){
                //添加车轮
                wheelClip =新OriginalBike_WheelClip();
                wheelClip.backTire.gotoAndStop(bikeInfo.data.BikeColor);
                wheelClip.frontTire.gotoAndStop(bikeInfo.data.BikeColor);
                的addChild(wheelClip);
                wheelClip.x = 0;
                wheelClip.y = 405;
                //添加自行车
                bitmapBike =新OriginalBike_Bitmap();
                的addChild(bitmapBike);
                bitmapBike.gotoAndStop(bikeInfo.data.BikeColor);
                bitmapBike.y = 399.80;
                //添加骑手
                //车手=新Rider_Original_bitmap();
                //的addChild(车手);
                //rider.y = 353.1
            }
            //bitmapBike.mouseChildren = FALSE;
            //bitmapBike.mouseEnabled = FALSE;
            //bitmapBike.cacheAsBitmapMatrix = bitmapBike.transform.concatenatedMatrix;
            //bitmapBike.cacheAsBitmap = TRUE;
            //
            跟踪(位图的自行车:+的getSize(bitmapBike));

            //rider.cacheAsBitmapMatrix = rider.transform.concatenatedMatrix;
            //rider.cacheAsBitmap = TRUE;
            rider.mouseChildren = FALSE;
            rider.mouseEnabled = FALSE;

            燃气press.addEventListener(的MouseEvent.MOUSE_DOWN,hitGas);
            燃气press.addEventListener(侦听MouseEvent.MOUSE_UP,releaseGas);
            brake.addEventListener(的MouseEvent.MOUSE_DOWN,hitBrake);
            brake.addEventListener(侦听MouseEvent.MOUSE_UP,releaseBrake);
            stage.addEventListener(KeyboardEvent.KEY_DOWN,useKeyboard);
            stage.addEventListener(KeyboardEvent.KEY_UP,stopUseKeyboard);
            的addEventListener(Event.ADDED_TO_STAGE,INIT);
            ScoreBoardFormat =新的TextFormat();
            ScoreBoardFormat.bold = TRUE;
            sprocketVector =新矢量<影片剪辑> ();
            sprocketPool =新SprocketPool(链轮,pool_SprocketAmount);
            stage.addEventListener(Event.RESIZE,resizeObjects);
            stage.dispatchEvent(新事件(Event.RESIZE));
            如果(Accelerometer.isSupported){
                //在移动设备
            }其他{
                //桌面
                重力= 15; //低值电话
                DY = 60; //低值电话
                backgroundDx = -160;
                buildingDx = -300;
                DX = 300; //速度和方向
            }
            //在一个轮子的自行车开始关闭
            bitmapBike.rotation = -45;
            rider.rotation = -45;
            wheelClip.x = -15;
            rider.x = bitmapBike.x;
            //添加第一链轮
            addSprocket();
        }

    //以下功能天然气和制动相关
        公共职能hitGas(E:的MouseEvent){
            e.stopImmediatePropagation();
            holdGas = TRUE;
            pressedBrake =无;
        }
        公共职能hitBrake(E:的MouseEvent){
            e.stopImmediatePropagation();
            pressedBrake =是;
        }
        公共职能releaseGas(E:的MouseEvent){
            e.stopImmediatePropagation();
            holdGas = FALSE;
        }
        公共职能releaseBrake(E:的MouseEvent){
            e.stopImmediatePropagation();
            pressedBrake =无;
        }




    //游戏循环
        公共职能gameLoop(五:事件):无效{
            e.stopImmediatePropagation();
            VAR timePassed:INT =的getTimer() -  lastTime;
            lastTime + = timePassed;

            如果(whichBike ==SupermotoDRZ400){
                 //保持车轮位置与自行车
                 wheelClip.rotation = bitmapBike.rotation;
                 wheelClip.x = bitmapBike.x;
                 //使轮胎旋转
                 wheelClip.frontTire.rotation + = 75 * timePassed / 1000;
                 wheelClip.backTire.rotation + = 75 * timePassed / 1000;
                 rider.rotation = bitmapBike.rotation  -  1;
                 rider.x = bitmapBike.x + 25;
            }否则,如果(whichBike ==OriginalDirtBike){
                //保持车轮位置与自行车
                wheelClip.rotation = bitmapBike.rotation  -  1.5;
                wheelClip.rotation = bitmapBike.rotation;
                wheelClip.x = bitmapBike.x + 16.5;
                //使轮胎旋转
                wheelClip.frontTire.rotation + = 75 * timePassed / 1000;
                wheelClip.backTire.rotation + = 75 * timePassed / 1000;
                //骑士
                rider.x = bitmapBike.x;
                rider.rotation = bitmapBike.rotation;
            }否则,如果(whichBike ==女妖){
                rider.rotation = bitmapBike.rotation;
                rider.x = bitmapBike.x;
                //第一轮
                wheelClip.x = bitmapBike.x;
                wheelClip.rotation = bitmapBike.rotation;
                wheelClip.frontTire.frontFace.rotation + = 75 * timePassed / 1000;
                wheelClip.frontTire.backFace.rotation + = 75 * timePassed / 1000;
                wheelClip.backTire.frontFace.rotation + = 75 * timePassed / 1000;
                wheelClip.backTire.backFace.rotation + = 75 * timePassed / 1000;
                //第二轮
                wheelClip2.x = bitmapBike.x;
                wheelClip2.rotation = bitmapBike.rotation;
                wheelClip2.farBackTire.frontFace.rotation + = 75 * timePassed / 1000;
                wheelClip2.farFrontTire.frontFace.rotation + = 75 * timePassed / 1000;
                wheelClip2.farFrontTire.backFace.rotation + = 75 * timePassed / 1000;
            }

            如果(弹出!= NULL){
                this.setChildIndex(弹出,this.numChildren  -  2);
            }
            this.setChildIndex(骑手,this.numChildren  -  1);
            //商店自行车当前旋转点
            VAR currRotation = bitmapBike.rotation;

            //使影子跟着​​自行车
            VAR bikeX:INT = bitmapBike.x;
            newShadow.x = bikeX + 150; //109.8;
            // ANITMATING司机!!!!
            如果(currRotation&其中; = -11){//这应该发生在一个较低的
                rider.gotoAndPlay(sitDown);
                sitDown = TRUE;
                newShadow.gotoAndStop(fullShadow);
            }
            如果(currRotation< = -15){
                newShadow.gotoAndStop(three4thShadow);
                轻松看= TRUE;
            }
            //只是改变影线的这一个
            如果(currRotation< = -25){
                newShadow.gotoAndStop(midShadow);
            }
            如果(currRotation< = -30){
                rider.gotoAndPlay(尽兴赏);
                轻松看= TRUE;
                newShadow.gotoAndStop(smallShadow);
            }
            如果(currRotation&其中; = -34){//最高
                rider.gotoAndPlay(LeanBack2);
                轻松看= TRUE;
                newShadow.gotoAndStop(smallestShadow);
            }
            如果(currRotation&其中; = -35){//最高
                rider.gotoAndPlay(LeanBack2);
                轻松看= TRUE;
                newShadow.gotoAndStop(allTheWayBack);
            }
            //如果玩家持有或打制动
            如果(pressedBrake ==是){//由于某种原因,相反的工作,现在
                VAR currBikePosition:INT;
                currBikePosition = bitmapBike.rotation;
                bitmapBike.rotation + = 2;
                currBikePosition = 0;
            }
            //重力牵引的自行车倒
            bitmapBike.rotation + =比重* timePassed / 1000;
            bitmapBike.rotation + =比重* timePassed / 1000;
            //如果玩家持气,做wheeliez
            如果(holdGas ==真){
                //使自行车车轮离地
                bitmapBike.rotation  -  = DY * timePassed / 1000;
                rider.rotation  -  = DY * timePassed / 1000;
            }
            //将自行车到中心,然后将建筑
            如果(bitmapBike.x< = 187){
                //招自行车
                bitmapBike.x + = DX * timePassed / 1000;
            }其他{
                //移动的建筑物和背景
                building1.x + = buildingDx * timePassed / 1000;
                building2.x + = buildingDx * timePassed / 1000;
                //建筑
                如果(building1.x< = -25){
                    building1.x = building2.x + building1.width;
                }否则如果(building2.x< = -25){
                    building2.x = building1.x + building2.width;
                }
                background1.x + = backgroundDx * timePassed / 1000;
                background2.x + = backgroundDx * timePassed / 1000;
                //背景
                如果(background1.x&所述; = 0){
                    background1.x = background2.x + background1.width;
                }否则如果(background2.x< = 0){
                    background2.x = background1.x + background2.width;
                }
            }
 

解决方案

在发布设置设为您的硬件加速的GPU,将瘦掉处理器

I have an app that I'm developing for iOS and Android using AS3. I'm currently having several performance issues with this project. This is my very first app and game. So any type of feedback or insight is greatly appreciated. My game is a dirt bike wheelie game. It allows the user to press a button (gasPress) to wheelie upward and another button (brake) to wheelie downward. Once the "gasPress" button is pressed, a boolean "holdGas" is set to true. In my "gameLoop" (Enter_Frame event), the bike is rotated upward, IF "holdGas" is equal to true. The code for pressing the brake is the same, except it rotates the bike donward. I have buildings that slide across the screen, creating the illusion that the bike is moving. The building movie clips are cached as bitmap. I use two instances of the same building movie clip. Once the first clip slides off the stage, it's placed behind the other. In a recycling kind of mechanism lol. The problem I'm having with this is, when i press the "gasPress" button, it lags before wheelie/rotating upward. When it lags, the buildings moving in the background skips. It happens every time. So if you keep tapping the gasPress, (which is part of the gameplay) the objects on the screen keep jumping. It makes the game unplayable. I've tested the buttons by completely removing the code to move the bike upward/downward and the game still skips. I've noticed more of a skip or lag when the gas is pressed and the bike rotates upward. I currently have the frame rate set to 32, it did the same at 24.

public function TheGame() {
            //Connect to tapjoy's ad network
            //tjClass = new TapJoyClass();
            //stage.scaleMode = StageScaleMode.NO_SCALE;
            //stage.align = StageAlign.TOP_LEFT; 
            //Give game focus so the keyboard keys will work on computer
            stage.focus = this;
            globalStage = this.stage;
            //Checks if ScoreData and Bike data shared object has been created, if not it creates
            scoreInfo = SharedObject.getLocal ( "ScoreData" );
            bikeInfo = SharedObject.getLocal ( "BikeData" );
            //scoreInfo.clear ();
            //bikeInfo.clear ();
            mostSprocketsCollected = scoreInfo.data.mostSprocketsCollected;
            //Handling  background
            background1 = new Background;
            background2 = new Background;
            addChild ( background1 );
            addChild ( background2 );
            background1.cacheAsBitmap = true;
            background2.cacheAsBitmap = true;
            background1.mouseChildren = false;
            background1.mouseEnabled = false;
            background2.mouseChildren = false;
            background2.mouseEnabled = false;
            background1.x = background1.width;
            background2.x = background1.x + background2.width;
            //Handling buildings
            building1 = new Buildings;
            building2 = new Buildings;
            addChild ( building1 );
            addChild ( building2 );
            building1.cacheAsBitmap = true;
            building2.cacheAsBitmap = true;
            building1.mouseChildren = false;
            building1.mouseEnabled = false;
            building2.mouseChildren = false;
            building2.mouseEnabled = false;
            building1.x = building1.width;
            building2.x = building1.x + building2.width;
            //Choose which bike will be used
            if( bikeInfo.data.EquippedBike == undefined ){
                //Start off with original bike
                whichBike = "OriginalDirtBike";
                bikeInfo.data.BikeColor = "OriginalDirtBike";
            }else{
                whichBike = bikeInfo.data.EquippedBike;
            }
            if( whichBike == "Banshee" ){
                //Add far wheels first
                wheelClip2 = new Banshee_Far_WheelClip;
                addChild ( wheelClip2 );
                //wheelClip2. = 208.30;
                wheelClip2.y = 350;
                //Add Banshee
                bitmapBike = new Banshee_Bitmap ();
                bitmapBike.gotoAndStop ( bikeInfo.data.BikeColor );
                addChild ( bitmapBike );
                bitmapBike.y = 399.80;
                bitmapBike.x = 0;
                //Add frontWheels
                wheelClip = new Banshee_WheelClip ();
                wheelClip.backTire.frontFace.gotoAndStop ( bikeInfo.data.BikeColor );
                wheelClip.frontTire.frontFace.gotoAndStop ( bikeInfo.data.BikeColor );
                addChild ( wheelClip );
                wheelClip.x = 187.70;
                wheelClip.y = 399;
            }else if( whichBike == "SupermotoDRZ400" ){
                //Add Wheels
                wheelClip = new WheelClip ();
                wheelClip.backTire.gotoAndStop ( bikeInfo.data.BikeColor );
                wheelClip.frontTire.gotoAndStop ( bikeInfo.data.BikeColor );
                addChild ( wheelClip );
                wheelClip.x = 0;
                wheelClip.y = 409.45;
                //Add bike
                bitmapBike = new SuperMoto_Bitmap ();
                bitmapBike.gotoAndStop ( bikeInfo.data.BikeColor );
                addChild ( bitmapBike );
                bitmapBike.y = 399.80;
            }else if( whichBike == "OriginalDirtBike" ){
                //Add wheels
                wheelClip = new OriginalBike_WheelClip ();
                wheelClip.backTire.gotoAndStop ( bikeInfo.data.BikeColor );
                wheelClip.frontTire.gotoAndStop ( bikeInfo.data.BikeColor );
                addChild ( wheelClip );
                wheelClip.x = 0;
                wheelClip.y = 405;
                //Add Bike
                bitmapBike = new OriginalBike_Bitmap ();
                addChild ( bitmapBike );
                bitmapBike.gotoAndStop ( bikeInfo.data.BikeColor );
                bitmapBike.y = 399.80;
                //Add rider
                //rider = new Rider_Original_bitmap ();
                //addChild ( rider );
                //rider.y = 353.1
            }
            //bitmapBike.mouseChildren = false;
            //bitmapBike.mouseEnabled = false;
            //bitmapBike.cacheAsBitmapMatrix = bitmapBike.transform.concatenatedMatrix;
            //bitmapBike.cacheAsBitmap = true;
            //
            trace ( "bitmap bike : " + getSize ( bitmapBike) );

            //rider.cacheAsBitmapMatrix = rider.transform.concatenatedMatrix;
            //rider.cacheAsBitmap = true;
            rider.mouseChildren = false;
            rider.mouseEnabled = false;

            gasPress.addEventListener ( MouseEvent.MOUSE_DOWN, hitGas );
            gasPress.addEventListener ( MouseEvent.MOUSE_UP, releaseGas );
            brake.addEventListener ( MouseEvent.MOUSE_DOWN, hitBrake );
            brake.addEventListener ( MouseEvent.MOUSE_UP, releaseBrake );
            stage.addEventListener ( KeyboardEvent.KEY_DOWN, useKeyboard);
            stage.addEventListener ( KeyboardEvent.KEY_UP, stopUseKeyboard);
            addEventListener ( Event.ADDED_TO_STAGE, init );
            ScoreBoardFormat = new TextFormat ();
            ScoreBoardFormat.bold = true; 
            sprocketVector = new Vector.< MovieClip > ();
            sprocketPool = new SprocketPool( Sprocket, pool_SprocketAmount );
            stage.addEventListener ( Event.RESIZE, resizeObjects );
            stage.dispatchEvent( new Event( Event.RESIZE ) );
            if( Accelerometer.isSupported ){
                //on mobile device
            }else{
                //on desktop
                gravity = 15; // low values for phone
                dy = 60; // low values for phone
                backgroundDx = -160;
                buildingDx  = -300;
                dx  = 300; // speed and direction
            }
            //start bike off in a wheelie
            bitmapBike.rotation = -45;
            rider.rotation = -45;
            wheelClip.x = -15;
            rider.x = bitmapBike.x;
            //Add the first sprocket
            addSprocket();
        }

    //Following Functions are Gas and Brake related
        public function hitGas (e:MouseEvent){
            e.stopImmediatePropagation();
            holdGas = true;
            pressedBrake = "no";
        }
        public function hitBrake (e:MouseEvent){
            e.stopImmediatePropagation();
            pressedBrake = "yes"; 
        }
        public function releaseGas (e:MouseEvent){
            e.stopImmediatePropagation();
            holdGas = false;
        }
        public function releaseBrake (e:MouseEvent){
            e.stopImmediatePropagation();
            pressedBrake = "no"; 
        }




    //Game Loop
        public function gameLoop ( e:Event ):void{
            e.stopImmediatePropagation();
            var timePassed:int = getTimer()-lastTime;
            lastTime += timePassed;

            if ( whichBike == "SupermotoDRZ400" ){
                 //Keep wheels in position with the bike
                 wheelClip.rotation = bitmapBike.rotation;
                 wheelClip.x = bitmapBike.x;
                 //make tires spin
                 wheelClip.frontTire.rotation += 75*timePassed/1000;
                 wheelClip.backTire.rotation += 75*timePassed/1000;
                 rider.rotation = bitmapBike.rotation - 1;
                 rider.x = bitmapBike.x + 25;
            }else if ( whichBike == "OriginalDirtBike" ){
                //Keep wheels in position with the bike
                wheelClip.rotation = bitmapBike.rotation - 1.5;
                wheelClip.rotation = bitmapBike.rotation;
                wheelClip.x = bitmapBike.x + 16.5;
                //make tires spin
                wheelClip.frontTire.rotation += 75*timePassed/1000;
                wheelClip.backTire.rotation += 75*timePassed/1000;
                //rider
                rider.x = bitmapBike.x;
                rider.rotation = bitmapBike.rotation;
            }else if ( whichBike == "Banshee" ){
                rider.rotation = bitmapBike.rotation;
                rider.x = bitmapBike.x;
                //First wheels
                wheelClip.x = bitmapBike.x;
                wheelClip.rotation = bitmapBike.rotation;
                wheelClip.frontTire.frontFace.rotation += 75*timePassed/1000;
                wheelClip.frontTire.backFace.rotation  += 75*timePassed/1000;
                wheelClip.backTire.frontFace.rotation += 75*timePassed/1000;
                wheelClip.backTire.backFace.rotation  += 75*timePassed/1000;
                //second wheels
                wheelClip2.x = bitmapBike.x;
                wheelClip2.rotation = bitmapBike.rotation;
                wheelClip2.farBackTire.frontFace.rotation += 75*timePassed/1000;
                wheelClip2.farFrontTire.frontFace.rotation += 75*timePassed/1000;
                wheelClip2.farFrontTire.backFace.rotation += 75*timePassed/1000;
            }

            if( popUp != null ){
                this.setChildIndex ( popUp, this.numChildren - 2 );
            }
            this.setChildIndex ( rider, this.numChildren - 1 );
            //Stores the bikes current rotation point
            var currRotation = bitmapBike.rotation;

            //make shadow follow bike
            var bikeX:int = bitmapBike.x;
            newShadow.x = bikeX + 150; //109.8;
            //ANITMATING THE DRIVER!!!!
            if( currRotation <= -11 ){ //This should occur at a lower
                rider.gotoAndPlay ( "sitDown" );
                sitDown = true;
                newShadow.gotoAndStop ( "fullShadow" );
            }
            if( currRotation <= -15 ){
                newShadow.gotoAndStop( "three4thShadow" );
                leanBack = true;
            }
            //just change shadow with this one
            if( currRotation <= -25 ){
                newShadow.gotoAndStop ( "midShadow" );
            }
            if( currRotation <= -30 ){
                rider.gotoAndPlay ( "LeanBack" );
                leanBack = true;
                newShadow.gotoAndStop ( "smallShadow" );
            }
            if( currRotation <= -34 ){ //Highest
                rider.gotoAndPlay ( "LeanBack2" );
                leanBack = true;
                newShadow.gotoAndStop ( "smallestShadow" );
            }
            if( currRotation <= -35 ){ //Highest
                rider.gotoAndPlay ( "LeanBack2" );
                leanBack = true;
                newShadow.gotoAndStop ( "allTheWayBack" );
            }
            //if player holds or hit the brake
            if( pressedBrake == "yes" ) { //for some reason the opposite is working right now
                var currBikePosition:int;
                currBikePosition = bitmapBike.rotation;
                bitmapBike.rotation += 2;
                currBikePosition = 0;
            }
            //gravity pulling bike down
            bitmapBike.rotation += gravity*timePassed/1000;
            bitmapBike.rotation += gravity*timePassed/1000;
            //if player holding gas, do wheeliez
            if( holdGas == true ){
                //Make bike wheelie
                bitmapBike.rotation -= dy*timePassed/1000;
                rider.rotation -= dy*timePassed/1000;
            }
            //Move Bike to center, then move buildings
            if( bitmapBike.x <=187 ){
                //move bike
                bitmapBike.x += dx*timePassed/1000;
            }else{
                //move buildings and background
                building1.x += buildingDx*timePassed/1000;
                building2.x += buildingDx*timePassed/1000;
                //buildings
                if( building1.x <= -25 ){
                    building1.x = building2.x + building1.width;
                }else if( building2.x <= -25 ){
                    building2.x = building1.x + building2.width;
                }
                background1.x += backgroundDx*timePassed/1000;
                background2.x += backgroundDx*timePassed/1000;
                //background
                if( background1.x <=0 ){
                    background1.x = background2.x + background1.width;
                }else if ( background2.x <=0 ){
                    background2.x = background1.x + background2.width;
                }
            }

解决方案

in Publish setting set your Hardware acceleration to GPU, that will lean off the processor

这篇关于我的游戏滞后,当我preSS按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆