* Устранение неполадок RPG-Engine (AS3): фрагмент кода «Несколько уровней» возвращает «нулевой» HitTestObject - PullRequest
0 голосов
/ 18 октября 2019

* Здравствуйте!
Я работаю над игровым движком с открытым исходным кодом, написанным на AS3
, и пытаюсь продвинуть MC в другую область / уровень ...

* Как это работает / Идея ...
Когда MC получает ключ, он используется для превращения kameHouseLocked в kameHouseOpen. Когда kameHouse настроен на открытие, игрок может удерживать «стрелку вверх» в направлении двери, чтобы продвигаться вперед. У меня есть два способа добиться этого, либо в рамках видеоклипа, либо вызывая любые вторые слои, необходимые слоям на сцену. В настоящее время мой код настроен так, что он не может ссылаться на kameHouse, который необходим для запуска события. Логика работала достаточно хорошо для ключа. Должен ли я убедиться, что на что-то ссылается в рамках видеоклипа? Нужен ли мне независимый фрагмент полностью для обработки столкновений? Буду признателен за любую помощь, я буду признателен вам за любые усилия / участие, заранее спасибо!

* Вывод выплевывает это?

    TypeError: Error #2007: Parameter hitTestObject must be non-null.
    	at flash.display::DisplayObject/_hitTest()
    	at flash.display::DisplayObject/hitTestObject()
    	at pokemongameexperiment/keyDownHandler()

* Код, о котором идет речь ...

import flash.display.MovieClip;
import flash.events.KeyboardEvent;
import flash.ui.Keyboard;
import flash.events.Event;
import flash.display.Stage;
import flash.events.MouseEvent;


mc.gotoAndStop("standingRight");
toggle_btn.stop();
hide_text.stop();
stop();
//backenvironment.kamiHouse.stop();


var keyCodeToListenForDown = '40'; //downarrow key
var keyCodeToListenForUp = '38'; //uparrow key
var keyCodeToListenForLeft = '37'; //leftarrow key
var keyCodeToListenForRight = '39'; //rightarrow key

var keySinglePress:Boolean = false;
var keyDoublePress:Boolean = false;
var timeToWaitForDoublePress:Number = 300;
var waitingForDoublePress:Boolean = false;

var leftBumping:Boolean = false;
var rightBumping:Boolean = false;
var upBumping:Boolean = false;
var downBumping:Boolean = false;
var leftBumpPoint:Point = new Point(-30, -55);
var rightBumpPoint:Point = new Point(30, -55);
var upBumpPoint:Point = new Point(0, -120);
var downBumpPoint:Point = new Point(0, 0);

var pp:Boolean=true;
var played:Boolean=false;
var mySound:Sound = new MySound();
var myChannel:SoundChannel = new SoundChannel();

var rightPressed:Boolean = new Boolean(false);
var leftPressed:Boolean = new Boolean(false);
var upPressed:Boolean = new Boolean(false);
var downPressed:Boolean = new Boolean(false);
var mcSpeed:Number = 10;

var roshiTimer:int = 0;
var roshiDuration:int = 0;
var roshiFacing:int = 0;
var roshiSpeed:Number = 3
var RF:Array = 
["roshiUpWalk", "roshiDownWalk",
 "roshiLeftWalk", "roshiRightWalk",];
var RX:Array = [0, 0, -1, 1];
var RY:Array = [-1, 1, 0, 0];

var kameKeyCollected:Boolean = false;
var kameHouseOpen:Boolean = false;

var currentLevel:int = 1;


//kameHouse(2).prevBtn.addEventListener(MouseEvent.CLICK, prevSection);

addEventListener(Event.ENTER_FRAME, onRoshi);
toggle_btn.addEventListener(MouseEvent.CLICK, togglePlay);

stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
stage.addEventListener(KeyboardEvent.KEY_UP, keyUpHandler);

stage.addEventListener(Event.ENTER_FRAME, gameLoop);
stage.addEventListener(KeyboardEvent.KEY_DOWN, handleKeyDown);
//kameHouse(2).nextBtn.addEventListener(MouseEvent.CLICK, nextSection);



//function prevSection(event:MouseEvent):void
//{
	//var thisLabel:String = pages.currentLabel;
	//var thisLabelNum:String = thisLabel.replace("sct", "");
	//var curNumber:Number = Number(thisLabelNum);
	//var prevNum:Number = curNumber - 1;
	//pages.gotoAndStop("sct" + prevNum);
//}

function handleKeyDown(keyEvent:KeyboardEvent) 
{ 
	if (keyEvent.keyCode == keyCodeToListenForDown)
	{
		keySinglePress = true;
		if (waitingForDoublePress){
			keyDoublePress = true;}
		
		waitingForDoublePress = true;
		
		setTimeout(function() {
		    waitingForDoublePress = false;
			keyDoublePress = false;
			}, timeToWaitForDoublePress);
	}
	if (keyDoublePress){
		trace('You logged a double press!')}
		else if (keySinglePress) {
		trace ('You logged a single press!');
	}

	if (keyEvent.keyCode == keyCodeToListenForUp)
	{
		keySinglePress = true;
		if (waitingForDoublePress){
			keyDoublePress = true;}
		
		waitingForDoublePress = true;
		
		setTimeout(function() {
		    waitingForDoublePress = false;
			keyDoublePress = false;
			}, timeToWaitForDoublePress);
	}
	if (keyDoublePress){
		trace('You logged a double press!')}
		else if (keySinglePress) {
		trace ('You logged a single press!');
	}
	    if (keyEvent.keyCode == keyCodeToListenForLeft)
	{
		    keySinglePress = true;
	    if (waitingForDoublePress){
			keyDoublePress = true;}
		
		waitingForDoublePress = true;
		
		setTimeout(function() {
		    waitingForDoublePress = false;
			keyDoublePress = false;
			}, timeToWaitForDoublePress);
	}
	if (keyDoublePress){
		trace('You logged a double press!')}
		else if (keySinglePress) {
		trace ('You logged a single press!');
	}
		if (keyEvent.keyCode == keyCodeToListenForRight)
	{
		keySinglePress = true;
		if (waitingForDoublePress){
			keyDoublePress = true;}
		
		waitingForDoublePress = true;
		
		setTimeout(function() {
		    waitingForDoublePress = false;
			keyDoublePress = false;
			}, timeToWaitForDoublePress);
	}
	if (keyDoublePress){
		trace('You logged a double press!')}
		else if (keySinglePress) {
		trace ('You logged a single press!');
	}
}

	
//hide_text.addEventListener(MouseEvent.CLICK, stopMovie);
function ppState(event:MouseEvent){
if(pp){
stop();
hide_text.gotoAndStop(3);
//hide_text.gotoAndStop('stopText');
pp = false;
}else{
//hide_text.addEventListener(MouseEvent.CLICK, playMovie);
	play();	
	hide_text.gotoAndStop(1);
	//hide_text.gotoAndStop('playText');
	pp = true;
}
}
hide_text.addEventListener(MouseEvent.CLICK, ppState);
															  
function togglePlay(event:MouseEvent):void
{
   (!played)? played = true : played = false;
   (played)? myChannel=mySound.play():SoundMixer.stopAll();

   (played)? toggle_btn.gotoAndStop(2):toggle_btn.gotoAndStop(1);
    myChannel.addEventListener(Event.SOUND_COMPLETE,soundCompleted);
}
function soundCompleted(event:Event):void
{
	played = false;
	toggle_btn.gotoAndStop(1);
}





function nextLevel():void
{
	currentLevel++;
	trace("Next Level: " + currentLevel);
	if(currentLevel == 2)
	{
		gotoLevel2();
	}
}
function gotoLevel2():void
{
	//gotoAndStop(2);
	//frontenvironment2.gotoAndStop;
	backenvironment.gotoAndStop(2);
	frontenvironment.gotoAndStop(2);
	gotoAndStop(frontenvironment2);
	//scrollx = 0;
	//scrolly = 0;
	//backenvironment.gotoAndStop
	//backenvironment.gotoAndStop
}

function gameLoop(loopEvent:Event):void 
{     	   
    if(rightPressed && mc.currentLabel !="walkingRight" && upPressed == false && downPressed == false)
	{ 
       mc.gotoAndStop("walkingRight");
    }
    if(rightPressed && mc.currentLabel =="walkingRight")
    {
	   if(mc.x < 800)
	   {
          mc.x += mcSpeed;
	   }

	   else if (backenvironment.x > -650) 
	   {
	   backenvironment.x -= mcSpeed; 
	   frontenvironment.x -= mcSpeed;
	   }
    } 
		if(keyDoublePress && mc.currentLabel =="walkingRight")
    {
	   if(mc.x < 800)
	   {
          mc.x += mcSpeed * 1.05;
	   }

	   else if (backenvironment.x > -650) 
	   {
	   backenvironment.x -= mcSpeed; 
	   frontenvironment.x -= mcSpeed;
	   }

    }
	
    if(leftPressed && mc.currentLabel !="walkingLeft" && upPressed == false && downPressed == false)
    {
       mc.gotoAndStop("walkingLeft");
    }
    if(leftPressed && mc.currentLabel =="walkingLeft")
    {
	   if(mc.x > 200)
	   {
          mc.x -= mcSpeed;
	   }
	   else if (backenvironment.x < -130)
	   {
	      backenvironment.x += mcSpeed;
	      frontenvironment.x += mcSpeed;
	   }
	}
	if(keyDoublePress && mc.currentLabel =="walkingLeft")
    {
	   if(mc.x > 200) 
	   {
          mc.x -= mcSpeed * 1.05;
       }
	   else if (backenvironment.x < -130) 
	   {
	      backenvironment.x += mcSpeed;
	      frontenvironment.x += mcSpeed;
	   }
    }
	
    if(upPressed && mc.currentLabel != "walkingUp" && rightPressed == false && leftPressed == false)  
	{
       mc.gotoAndStop("walkingUp");
    }
    if(upPressed && mc.currentLabel == "walkingUp")
    {
	   if(mc.y > 200) 
	   {
          mc.y -= mcSpeed;10
       }
	   else if (backenvironment.y < -10) 
	   {
	      backenvironment.y += mcSpeed;
	      frontenvironment.y += mcSpeed;
	   }
	}
	
	   if(keyDoublePress && mc.currentLabel =="walkingUp")
       {
	   if(mc.y > 200) 
	   {
          mc.y -= mcSpeed * 1.05;10
       }
	   else if (backenvironment.y < -10) 
	   {
	      backenvironment.y += mcSpeed;
	      frontenvironment.y += mcSpeed;
	   }
  
	}
	   
    if(downPressed && mc.currentLabel != "walkingDown" && rightPressed == false && leftPressed == false)
    {
       mc.gotoAndStop("walkingDown");
    }
	
    if (downPressed && mc.currentLabel == "walkingDown")
    {
	   if(mc.y < 485) 
	   {
          mc.y += mcSpeed;
       }
	   else if (backenvironment.y > -577) 
       {
		   backenvironment.y -= mcSpeed;
		   frontenvironment.y -= mcSpeed;
       }
    }
    if (keyDoublePress && mc.currentLabel == "walkingDown")
    {
	  if(mc.y < 485)
	  {
		  mc.y += (mcSpeed * 1.05);
	  }
	  else if (backenvironment.y > -577)
	  {
		  backenvironment.y -= mcSpeed;
		  frontenvironment.y -= mcSpeed;
	  } 
	}
//add more walking functionality here if needed (ex: multi-directional).
}   


//Roshi's_Brain:
function onRoshi(e:Event):void
{
   if(mc.hitTestObject(backenvironment.Roshi))
   {
      myText.text = "Master Roshi: R- Red? Oh dear... this is bad. I've barely introduced myself. I'm Master Roshi, headmaster of the Turtle School of Martial Arts!";	
   }
   else
   {
	  myText.text = "Master Roshi: Red... You have to find Goku. My back, it's delicate!"; 

      roshiTimer ++;	

      if (roshiTimer > roshiDuration)
      {
         roshiDuration = 10 + Math.random() * 25;
         roshiTimer = 0;
		
         while (backenvironment.Roshi.currentLabel == RF[roshiFacing])
         {
            roshiFacing = Math.random() * 4;
         }

      backenvironment.Roshi.gotoAndStop(RF[roshiFacing]);
   }

    backenvironment.Roshi.x += RX[roshiFacing] * roshiSpeed;
    backenvironment.Roshi.y += RY[roshiFacing] * roshiSpeed;
}
if(kameKeyCollected == false)
{ // if we still haven't collected the key
	if(mc.hitTestObject(backenvironment.kameKey))
	{ // and if the player collides with the key
		backenvironment.kameKey.visible = false; // hide the key from view
		kameKeyCollected = true; // set our Boolean to true
	}
	
}

if(kameHouseOpen == false)
{ // if the door hasn't been opened yet
	if(kameKeyCollected == true)
	{ // and if the player has already collected the key
    	if(mc.hitTestObject(backenvironment.kameHouse))
		{ // check if the door and the player are touching
        // if all of these conditions are met...
        backenvironment.kameHouse.gotoAndStop(2); // ...switch the door's image to its 2nd frame
        kameHouseOpen = true; // ...set the variable to true
        }
    }
}

}
function keyDownHandler(keyEvent:KeyboardEvent):void
{
   if(keyEvent.keyCode == Keyboard.RIGHT)
   {
	   rightPressed = true;
   }
   else if(keyEvent.keyCode == Keyboard.LEFT)
   {
	   leftPressed = true;
   }
   else if(keyEvent.keyCode == Keyboard.DOWN)
   {
	   downPressed = true;
   }
   else if(keyEvent.keyCode == Keyboard.UP)
   {
	   upPressed = true;
	   if(kameHouseOpen && mc.hitTestObject(backenvironment.kameHouse.kameHouseLocked))
	   { 
	      nextLevel(); 
	   }
   }
}

function keyUpHandler(keyEvent:KeyboardEvent):void
{
   if(keyEvent.keyCode == Keyboard.RIGHT)
   {
	   rightPressed = false;
	   mc.gotoAndStop("standingRight");
   }
   else if(keyEvent.keyCode == Keyboard.LEFT)
   {
	leftPressed = false;
	mc.gotoAndStop("standingLeft");
   }
   else if (keyEvent.keyCode == Keyboard.DOWN)
   {
       downPressed = false;
	   mc.gotoAndStop("standingDown");
   }
   else if(keyEvent.keyCode == Keyboard.UP)
   {
	   upPressed = false;
	   mc.gotoAndStop("standingUp");
   }
}

Пересмотренный код

///////////////////////////////////////////////////////////////////////////
///Dev Notes: Poke Ball Z (Ver. 0.3.8)//////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
import flash.display.MovieClip;
import flash.events.KeyboardEvent;
import flash.ui.Keyboard;
import flash.events.Event;
import flash.display.Stage;
import flash.events.MouseEvent;


mc.gotoAndStop("standingRight");
toggle_btn.stop();
hide_text.stop();
stop();
//backenvironment.kamiHouse.stop();


var keyCodeToListenForDown = '40'; //downarrow key
var keyCodeToListenForUp = '38'; //uparrow key
var keyCodeToListenForLeft = '37'; //leftarrow key
var keyCodeToListenForRight = '39'; //rightarrow key

var keySinglePress:Boolean = false;
var keyDoublePress:Boolean = false;
var timeToWaitForDoublePress:Number = 300;
var waitingForDoublePress:Boolean = false;

var leftBumping:Boolean = false;
var rightBumping:Boolean = false;
var upBumping:Boolean = false;
var downBumping:Boolean = false;
var leftBumpPoint:Point = new Point(-30, -55);
var rightBumpPoint:Point = new Point(30, -55);
var upBumpPoint:Point = new Point(0, -120);
var downBumpPoint:Point = new Point(0, 0);

var pp:Boolean=true;
var played:Boolean=false;
var mySound:Sound = new MySound();
var myChannel:SoundChannel = new SoundChannel();

var rightPressed:Boolean = new Boolean(false);
var leftPressed:Boolean = new Boolean(false);
var upPressed:Boolean = new Boolean(false);
var downPressed:Boolean = new Boolean(false);
var mcSpeed:Number = 10;

var roshiTimer:int = 0;
var roshiDuration:int = 0;
var roshiFacing:int = 0;
var roshiSpeed:Number = 3
var RF:Array = 
["roshiUpWalk", "roshiDownWalk",
 "roshiLeftWalk", "roshiRightWalk",];
var RX:Array = [0, 0, -1, 1];
var RY:Array = [-1, 1, 0, 0];

var kameKeyCollected:Boolean = false;
var kameHouseOpen:Boolean = false;

var currentLevel:int = 1;


//kameHouse(2).prevBtn.addEventListener(MouseEvent.CLICK, prevSection);

addEventListener(Event.ENTER_FRAME, onRoshi);
toggle_btn.addEventListener(MouseEvent.CLICK, togglePlay);

stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
stage.addEventListener(KeyboardEvent.KEY_UP, keyUpHandler);

stage.addEventListener(Event.ENTER_FRAME, gameLoop);
stage.addEventListener(KeyboardEvent.KEY_DOWN, handleKeyDown);
//kameHouse(2).nextBtn.addEventListener(MouseEvent.CLICK, nextSection);



//function prevSection(event:MouseEvent):void
//{
	//var thisLabel:String = pages.currentLabel;
	//var thisLabelNum:String = thisLabel.replace("sct", "");
	//var curNumber:Number = Number(thisLabelNum);
	//var prevNum:Number = curNumber - 1;
	//pages.gotoAndStop("sct" + prevNum);
//}

function handleKeyDown(keyEvent:KeyboardEvent) 
{ 
	if (keyEvent.keyCode == keyCodeToListenForDown)
	{
		keySinglePress = true;
		if (waitingForDoublePress){
			keyDoublePress = true;}
		
		waitingForDoublePress = true;
		
		setTimeout(function() {
		    waitingForDoublePress = false;
			keyDoublePress = false;
			}, timeToWaitForDoublePress);
	}
	if (keyDoublePress){
		trace('You logged a double press!')}
		else if (keySinglePress) {
		trace ('You logged a single press!');
	}

	if (keyEvent.keyCode == keyCodeToListenForUp)
	{
		keySinglePress = true;
		if (waitingForDoublePress){
			keyDoublePress = true;}
		
		waitingForDoublePress = true;
		
		setTimeout(function() {
		    waitingForDoublePress = false;
			keyDoublePress = false;
			}, timeToWaitForDoublePress);
	}
	if (keyDoublePress){
		trace('You logged a double press!')}
		else if (keySinglePress) {
		trace ('You logged a single press!');
	}
	    if (keyEvent.keyCode == keyCodeToListenForLeft)
	{
		    keySinglePress = true;
	    if (waitingForDoublePress){
			keyDoublePress = true;}
		
		waitingForDoublePress = true;
		
		setTimeout(function() {
		    waitingForDoublePress = false;
			keyDoublePress = false;
			}, timeToWaitForDoublePress);
	}
	if (keyDoublePress){
		trace('You logged a double press!')}
		else if (keySinglePress) {
		trace ('You logged a single press!');
	}
		if (keyEvent.keyCode == keyCodeToListenForRight)
	{
		keySinglePress = true;
		if (waitingForDoublePress){
			keyDoublePress = true;}
		
		waitingForDoublePress = true;
		
		setTimeout(function() {
		    waitingForDoublePress = false;
			keyDoublePress = false;
			}, timeToWaitForDoublePress);
	}
	if (keyDoublePress){
		trace('You logged a double press!')}
		else if (keySinglePress) {
		trace ('You logged a single press!');
	}
}

	
//hide_text.addEventListener(MouseEvent.CLICK, stopMovie);
function ppState(event:MouseEvent){
if(pp){
stop();
hide_text.gotoAndStop(3);
//hide_text.gotoAndStop('stopText');
pp = false;
}else{
//hide_text.addEventListener(MouseEvent.CLICK, playMovie);
	play();	
	hide_text.gotoAndStop(1);
	//hide_text.gotoAndStop('playText');
	pp = true;
}
}
hide_text.addEventListener(MouseEvent.CLICK, ppState);
															  
function togglePlay(event:MouseEvent):void
{
   (!played)? played = true : played = false;
   (played)? myChannel=mySound.play():SoundMixer.stopAll();

   (played)? toggle_btn.gotoAndStop(2):toggle_btn.gotoAndStop(1);
    myChannel.addEventListener(Event.SOUND_COMPLETE,soundCompleted);
}
function soundCompleted(event:Event):void
{
	played = false;
	toggle_btn.gotoAndStop(1);
}





function nextLevel():void
{
	currentLevel++;
	trace("Next Level: " + currentLevel);
	if(currentLevel == 2)
	{
		gotoLevel2();
	}
}
function gotoLevel2():void
{
	//gotoAndStop(2);
	//frontenvironment2.gotoAndStop;
	backenvironment.gotoAndStop(2);
	backenvironment.kameHouseOpen.gotoAndStop(1);
	frontenvironment.gotoAndStop(2);
	gotoAndStop(frontenvironment2);
	//scrollx = 0;
	//scrolly = 0;
	//backenvironment.gotoAndStop
	//backenvironment.gotoAndStop
}
function keyUpHandler(keyEvent:KeyboardEvent):void
{
   if(keyEvent.keyCode == Keyboard.RIGHT)
   {
	   rightPressed = false;
	   mc.gotoAndStop("standingRight");
   }
   else if(keyEvent.keyCode == Keyboard.LEFT)
   {
	leftPressed = false;
	mc.gotoAndStop("standingLeft");
   }
   else if (keyEvent.keyCode == Keyboard.DOWN)
   {
       downPressed = false;
	   mc.gotoAndStop("standingDown");
   }
   else if(keyEvent.keyCode == Keyboard.UP)
   {
	   upPressed = false;
	   mc.gotoAndStop("standingUp");
   }
}
function keyDownHandler(keyEvent:KeyboardEvent):void
{
   if(keyEvent.keyCode == Keyboard.RIGHT)
   {
	   rightPressed = true;
   }
   else if(keyEvent.keyCode == Keyboard.LEFT)
   {
	   leftPressed = true;
   }
   else if(keyEvent.keyCode == Keyboard.DOWN)
   {
	   downPressed = true;
   }
   else if(keyEvent.keyCode == Keyboard.UP)
   {
	   upPressed = true;
	   if(kameHouseOpen && mc.hitTestObject(backenvironment.kameHouse))
	   { 
	      nextLevel(); 
	   }
   }
}

function gameLoop(loopEvent:Event):void 
{     	   
    if(rightPressed && mc.currentLabel !="walkingRight" && upPressed == false && downPressed == false)
	{ 
       mc.gotoAndStop("walkingRight");
    }
    if(rightPressed && mc.currentLabel =="walkingRight")
    {
	   if(mc.x < 800)
	   {
          mc.x += mcSpeed;
	   }

	   else if (backenvironment.x > -650) 
	   {
	   backenvironment.x -= mcSpeed; 
	   frontenvironment.x -= mcSpeed;
	   }
    } 
		if(keyDoublePress && mc.currentLabel =="walkingRight")
    {
	   if(mc.x < 800)
	   {
          mc.x += mcSpeed * 1.05;
	   }

	   else if (backenvironment.x > -650) 
	   {
	   backenvironment.x -= mcSpeed; 
	   frontenvironment.x -= mcSpeed;
	   }

    }
	
    if(leftPressed && mc.currentLabel !="walkingLeft" && upPressed == false && downPressed == false)
    {
       mc.gotoAndStop("walkingLeft");
    }
    if(leftPressed && mc.currentLabel =="walkingLeft")
    {
	   if(mc.x > 200)
	   {
          mc.x -= mcSpeed;
	   }
	   else if (backenvironment.x < -130)
	   {
	      backenvironment.x += mcSpeed;
	      frontenvironment.x += mcSpeed;
	   }
	}
	if(keyDoublePress && mc.currentLabel =="walkingLeft")
    {
	   if(mc.x > 200) 
	   {
          mc.x -= mcSpeed * 1.05;
       }
	   else if (backenvironment.x < -130) 
	   {
	      backenvironment.x += mcSpeed;
	      frontenvironment.x += mcSpeed;
	   }
    }
	
    if(upPressed && mc.currentLabel != "walkingUp" && rightPressed == false && leftPressed == false)  
	{
       mc.gotoAndStop("walkingUp");
    }
    if(upPressed && mc.currentLabel == "walkingUp")
    {
	   if(mc.y > 200) 
	   {
          mc.y -= mcSpeed;10
       }
	   else if (backenvironment.y < -10) 
	   {
	      backenvironment.y += mcSpeed;
	      frontenvironment.y += mcSpeed;
	   }
	}
	
	   if(keyDoublePress && mc.currentLabel =="walkingUp")
       {
	   if(mc.y > 200) 
	   {
          mc.y -= mcSpeed * 1.05;10
       }
	   else if (backenvironment.y < -10) 
	   {
	      backenvironment.y += mcSpeed;
	      frontenvironment.y += mcSpeed;
	   }
  
	}
	   
    if(downPressed && mc.currentLabel != "walkingDown" && rightPressed == false && leftPressed == false)
    {
       mc.gotoAndStop("walkingDown");
    }
	
    if (downPressed && mc.currentLabel == "walkingDown")
    {
	   if(mc.y < 485) 
	   {
          mc.y += mcSpeed;
       }
	   else if (backenvironment.y > -577) 
       {
		   backenvironment.y -= mcSpeed;
		   frontenvironment.y -= mcSpeed;
       }
    }
    if (keyDoublePress && mc.currentLabel == "walkingDown")
    {
	  if(mc.y < 485)
	  {
		  mc.y += (mcSpeed * 1.05);
	  }
	  else if (backenvironment.y > -577)
	  {
		  backenvironment.y -= mcSpeed;
		  frontenvironment.y -= mcSpeed;
	  } 
	}
//add more walking functionality here if needed (ex: multi-directional).
}   


//Roshi's_Brain:
function onRoshi(e:Event):void
{
   if(mc.hitTestObject(backenvironment.Roshi))
   {
      myText.text = "Master Roshi: R- Red? Oh dear... this is bad. I've barely introduced myself. I'm Master Roshi, headmaster of the Turtle School of Martial Arts!";	
   }
   else
   {
	  myText.text = "Master Roshi: Red... You have to find Goku. My back, it's delicate!"; 

      roshiTimer ++;	

      if (roshiTimer > roshiDuration)
      {
         roshiDuration = 10 + Math.random() * 25;
         roshiTimer = 0;
		
         while (backenvironment.Roshi.currentLabel == RF[roshiFacing])
         {
            roshiFacing = Math.random() * 4;
         }

      backenvironment.Roshi.gotoAndStop(RF[roshiFacing]);
   }

    backenvironment.Roshi.x += RX[roshiFacing] * roshiSpeed;
    backenvironment.Roshi.y += RY[roshiFacing] * roshiSpeed;
}
if(kameKeyCollected == false)
{ // if we still haven't collected the key
	if(mc.hitTestObject(backenvironment.kameKey))
	{ // and if the player collides with the key
		backenvironment.kameKey.visible = false; // hide the key from view
		kameKeyCollected = true; // set our Boolean to true
	}
	
}

if(kameHouseOpen == false)
{ // if the door hasn't been opened yet
	if(kameKeyCollected == true)
	{ // and if the player has already collected the key
    	if(mc.hitTestObject(backenvironment.kameHouse))
		{ // check if the door and the player are touching
        // if all of these conditions are met...
        backenvironment.kameHouseOpen.gotoAndStop(1); // ...switch the door's image to its 2nd frame
		kameHouseOpen = true; // ...set the variable to true
        }
    }
}
}


//function nextSection(event:MouseEvent):void
//{
	//var thisLabel:String = currentLabel; //gets current frame label as string
	//var thisLabelNum:String = thisLabel.replace("sct", ""); //cuts the leading letters off of the number
	//var curNumber:Number = Number(thisLabelNum); //converts that string numbers to a real number
	//if (curNumber < 5)
    //{
		//var nextNum:Number = curNumber + 1;
		//gotoAndStop("scl" + nextNum);
	//}
//}

Новый код ошибки

You logged a single press!
Next Level: 2
ArgumentError: Error #2109: Frame label null not found in scene Scene 1.
	at flash.display::MovieClip/gotoAndStop()
	at pokemongameexperiment/gotoLevel2()
	at pokemongameexperiment/nextLevel()
	at pokemongameexperiment/keyDownHandler()
You logged a single press!
You logged a single press!
You logged a single press!
You logged a single press!
Next Level: 3
You logged a single press! //etc.

* Newgrounds Ссылка для проверки игры как есть ... https://www.newgrounds.com/dump/item/49a43c79e613ec32e547dc1ae8851978

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...