私のコードには小さな問題があります。3 つのクラスすべてをリンクして、単純なプラットフォーマーを作成したいと考えています。コードは次のとおりです。
配列クラス:
package
{
import flash.display.*;
public dynamic class setupStage extends Thiny
{
var mapWid = 24;
var mapHei = 40;
var tileSide = 10;
var totalTiles = mapWid * mapHei;
var cell:tile=new tile();
var firstStage:Array=[
/*1*/[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]
/*2*/[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1]
/*3*/[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1]
/*4*/[1,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1]
/*5*/[1,0,0,0,1,0,0,0,0,0,1,1,1,1,1,0,0,0,1,1,1,1,0,1]
/*6*/[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1]
/*7*/[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1]
/*8*/[1,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1]
/*9*/[1,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,1]
/*10*/[1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,1]
/*11*/[1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,1]
/*12*/[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1]
/*13*/[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1]
/*14*/[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1]
/*15*/[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1]
/*16*/[1,0,0,0,0,0,0,0,0,0,0,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1]
/*36*/[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1]
/*37*/[1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1]
/*38*/[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1]
/*39*/[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1]
/*40*/[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]
];
function setupStage()
{
trace("access granted");
}
function drawMap():void
{
for (var i:int=0; i<mapWid; i++)
{
for (var u:int=0; u<mapHei; u++)
{
cell.gotoAndStop(firstStage[i][u]+1);
cell.x = tileSide * i;
cell.y = tileSide * u;
with (stage)
{
stage.addChild(cell);
}
}
}
}
}
}
移動クラス:
package
{
import flash.display.*;
import flash.utils.*;
import flash.events.*;
import flash.sampler.StackFrame;
public dynamic class JAJEBIE extends Thiny{
var granica:setupStage = new setupStage();
var thinX = 0;
var thinY = 0;
var acc = 6;
var thin:thiny1 = new thiny1();
var przycisk:Object = {};
stage.addEventListener(KeyboardEvent.KEY_DOWN,Move);
stage.addEventListener(KeyboardEvent.KEY_UP,Halt);
//with (thin){addEventListener(Event.ENTER_FRAME,Opadanie);}
function wrzut():void
{
addChild(thin);
thin.x = 200;
thin.y = 390;
}
function Move(k:KeyboardEvent):void
{
przycisk[k.keyCode] = true;
if (przycisk[Keyboard.LEFT] && granica.firstStage[thinX][thinY] == 0 && granica.firstStage[thinX - 1][thinY] == 0)
{
thin.x = thin.x - 10;
}
if (przycisk[Keyboard.RIGHT] && granica.firstStage[thinX][thinY] == 0 && granica.firstStage[thinX - 1][thinY] == 0)
{
thin.x = thin.x + 10;
}
if (przycisk[Keyboard.SPACE])
{
acc = 3;
thin.y = thin.y + 30;
}
}
//function Opadanie(Event);
//{
//thin.y = thin.y - 30;
//}
function Halt(k:KeyboardEvent):void
{
przycisk[k.keyCode] = false;
}
}
}
メインの fla ファイル:
stop();
import flash.events.Event;
import flash.display.DisplayObject;
import flash.utils.*;
import flash.events.*;
import flash.sampler.StackFrame;
stage.addEventListener(Event.ENTER_FRAME,initialize);
function initialize(main_event:Event):void{
with(setupStage){drawMap();};
with(JAJEBIE){wrzut();};
stage.removeEventListener(Event.ENTER_FRAME,initialize);
}
多くのことを試しましたが、コードの問題をすべて削除した後でも、コンパイラはエラーをスローし続けました。メイン クラスはすべてにパッチを適用したくないようです。どんな助けでも大歓迎です!ありがとう!