生成されたグリッドをキーボードで移動しようとしています... .swf ファイルを試してみると、実行されますが、キーボードです... これはマリオのようなプラットフォーム ゲーム用なので、そこに認識されていないコード行を修正する必要があります、しかし、私は彼らがすることを保証します!
だから、これは私のASです:
var map:Array = [
[1,1,1,1,1,1,10,0,0,11,1,1,1,1,1,1,1,1,1,1],
[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,0,1],
[1,0,0,0,0,0,6,1,0,0,4,4,4,4,0,0,6,1,0,1],
[1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
[1,0,0,0,1,6,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
[1,0,0,0,0,6,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
[1,0,0,0,0,6,0,0,1,0,0,1,0,0,1,0,0,1,2,1],
[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
[1,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
[1,1,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,1,3,1],
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]
];
var stock:Array = [
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
];
function createMap():void{
for (var i:int=0; i<20; i++){
for (var j:int=0; j<15; j++){
var T:int = 32
var dT:int = T*.5
var f:int = map[j][i]
if(f>0) {
var t:Block = new Block()
t.x= i*T;
t.y= j*T;
t.gotoAndStop(f)
grid.addChild(t)
}
}
}
}
var grid:MovieClip = new MovieClip();
addChild(grid);
createMap();
stage.addEventListener(KeyboardEvent.KEY_DOWN, pushin);
stage.addEventListener(KeyboardEvent.KEY_UP, pushout);
var right:Boolean=false;
var left:Boolean=false;
var up:Boolean=false;
var down:Boolean=false;
var lateral:Boolean = false;
var saute:Boolean = false ;
var none:Boolean = true
function paramMap():void {
grid.sens = int(right)-int(left);
grid.up = int(up)-int(down)
grid.jump = -int(up)*11
none = !right && !left && !up && !down
lateral = right || left;
function movingGrid():void{
var L:int
var C:int
var Ls:int
var Cs:int
var A:Object
var B:Object
var Y:Number
var P:Array
with(grid){
x += vit*sens;
L = y/T;
C = x/T;
Ls = (y+T-1)/T;
Cs = (x+vit*sens)/T;
P = checkLateral(grid,L,Cs,vit*2,(y-dT)/T)
L = P[0]
Cs = P[1]
A = stock[L][C]
B = stock[Ls][C]
Y = (L-1)*T
y += gravite;
if (gravite++>T) gravite=T
}
}
}
function pushin(event:KeyboardEvent):void {
if (event.keyCode == 38) up = true;
if (event.keyCode == 40) down = true;
if (event.keyCode == 39) right = true;
if (event.keyCode == 37) left = true;
}
function pushout(event:KeyboardEvent):void {
if (event.keyCode == 38) up = false;
if (event.keyCode == 40) down = false;
if (event.keyCode == 39) right = false;
if (event.keyCode == 37) left = false;
}
ありがとうございました !