lvl1 をプレイすると、Array ビルドは正常に行われますが、後で別のレベルを実行したい場合は、何もビルドされません。他のレベルを実行したい場合、lvl1 を実行しなくても、配列の最初の 5 列のみがビルドされます。最後に、タイマーを終了すると、次のバグがあります。
TypeError: Error #2007: Parameter hitTestObject must be non-null.
at flash.display::DisplayObject/_hitTest()
at flash.display::DisplayObject/hitTestObject()
at projsolo_fla::MainTimeline/collisions()[projsolo_fla.MainTimeline::frame3:133]
これは私のフレーム1コードです:
import flash.events.MouseEvent;
//--- Variables: ---
var toucheA: Boolean = false;
var toucheZ: Boolean = false;
var toucheE: Boolean = false;
var toucheR: Boolean = false;
var toucheT: Boolean = false;
var map:Sprite=new Sprite();
//--- Ecouteurs: ---
stage.addEventListener (KeyboardEvent.KEY_DOWN, pressee);
stage.addEventListener (KeyboardEvent.KEY_UP, relachee);
btnLevel.addEventListener (MouseEvent.CLICK, menuLevel);
//--- autre: ---
stop();
stage.displayState=StageDisplayState.FULL_SCREEN;
stage.scaleMode=StageScaleMode.EXACT_FIT;
stage.addEventListener (Event.ENTER_FRAME, moove);
//--- Fonction: ---
function pressee (e:KeyboardEvent):void{
switch (e.keyCode){
case 65 :
toucheA=true;
Pac.y=55;
break;
case 90 :
toucheZ=true;
Pac.y=105;
break;
case 69 :
toucheE=true;
Pac.y=155;
break;
case 82 :
toucheR=true;
Pac.y=205;
break;
case 84 :
toucheT=true;
Pac.y=255;
break;
default :
break;
}
}
function relachee (e:KeyboardEvent):void{
switch (e.keyCode){
case 65 :
toucheA=false;
break;
case 90 :
toucheZ=false;
break;
case 69 :
toucheE=false;
break;
case 82 :
toucheR=false;
break;
case 84 :
toucheT=false;
break;
default :
break;
}
}
function moove (e:Event):void{
map.x-=5;
}
function menuLevel (e:MouseEvent):void{
gotoAndStop (2);
}
これは私のフレーム 2 コードです:
import flash.events.MouseEvent;
btnMusique1.addEventListener (MouseEvent.CLICK, playLVL1);
btnMusique2.addEventListener (MouseEvent.CLICK, playLVL2);
btnMusique3.addEventListener (MouseEvent.CLICK, playLVL3);
btnMusique4.addEventListener (MouseEvent.CLICK, playLVL4);
function playLVL1 (e:MouseEvent):void{
gotoAndStop (3);
lvl1 ();
}
function playLVL2 (e:MouseEvent):void{
gotoAndStop (3);
lvl2();
}
function playLVL3 (e:MouseEvent):void{
gotoAndStop (3);
lvl3();
}
function playLVL4 (e:MouseEvent):void{
gotoAndStop(3);
lvl4();
}
これは私のフレーム3コードです:
import flash.ui.Keyboard;
import flash.events.Event;
import flash.sampler.NewObjectSample;
import flash.utils.Timer;
import flash.events.TimerEvent;
import flash.media.SoundChannel;
import flashx.textLayout.formats.BlockProgression;
//--- Variables: ---
stop();
var timer1: Timer=new Timer (70000,1);
var points: Number = 0;
stage.addChild(map);
var tableau1: 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,1,1,1,0,0,0,0,0,1,1,1,0,0,0,0,0,1,1,1,0,1,1,1,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,1,1,0,0,0,0,1,1,1,0,0,0,0,0,1,1,1,1,1,0,0,0,1,1,1,1,0,0,0,0,0,0,1,1,0,0,0,1,1,0,1,1,1,0,1,1,1,0,0,0,0,1,1],
[0,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,1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0,0,0,0,0,1,0,1,0,1,0,1,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1]];
var L:int=0;
var C:int=0;
// création du tableau.
function lvl1 () {
for (L=0; L<tableau1.length ;L++){
for(C=0; C<tableau1[1].length ;C++){
if (tableau1[L][C]==1){
var Block: block=new block();
map.addChild(Block);
Block.name="Block_"+L+"_"+C;
Block.x=1620+C*60;
Block.y=55+L*50;
Block.addEventListener (Event.ENTER_FRAME, collisions);
stage.removeEventListener (Event.ENTER_FRAME, lvl1);
}
}
}
}
function lvl2 () {
for (L=0; L<tableau2.length;L++){
for(C=0; C<tableau2.length;C++){
if (tableau2[L][C]==1){
var Block: block=new block();
map.addChild(Block);
Block.name="Block_"+L+"_"+C;
Block.x=1620+C*60;
Block.y=55+L*50;
Block.addEventListener (Event.ENTER_FRAME, collisions);
stage.removeEventListener (Event.ENTER_FRAME, lvl2);
}
}
}
}
function lvl3 () {
for (L=0; L<tableau3.length;L++){
for(C=0; C<tableau3.length;C++){
if (tableau3[L][C]==1){
var Block: block=new block();
map.addChild(Block);
Block.name="Block_"+L+"_"+C;
Block.x=1620+C*60;
Block.y=55+L*50;
Block.addEventListener (Event.ENTER_FRAME, collisions);
stage.removeEventListener (Event.ENTER_FRAME, lvl3);
}
}
}
}
function lvl4 () {
for (L=0; L<tableau4.length;L++){
for(C=0; C<tableau4.length;C++){
if (tableau4[L][C]==1){
var Block: block=new block();
map.addChild(Block);
Block.name="Block_"+L+"_"+C;
Block.x=1620+C*60;
Block.y=55+L*50;
Block.addEventListener (Event.ENTER_FRAME, collisions);
stage.removeEventListener (Event.ENTER_FRAME, lvl4);
}
}
}
}
//--- Ecouteurs: ---
timer1.addEventListener (TimerEvent.TIMER, stoplvl1);
timer1.start();
//--- Fonctions: ---
function stoplvl1 (e:TimerEvent) :void{
stage.removeEventListener(Event.ENTER_FRAME, moove);
for (L=0; L<tableau1.length ;L++){
for(C=0; C<tableau1[1].length ;C++){
if (tableau1[L][C]==1){
tableau1[L][C]=0;
}
}
}
stage.removeChild(map);
gotoAndStop(4);
}
function collisions (e:Event):void {
if(e.target.hitTestObject(Pac)){
for (L=0; L<tableau1.length ;L++){
for(C=0; C<tableau1[1].length ;C++){
if (tableau1[L][C]==1){
tableau1[L][C]=0;
}
}
}
e.target.nextFrame();
e.target.removeEventListener(Event.ENTER_FRAME, collisions);
points+=1000;
Scorelvl.text = points.toString();
}
}
これは私のフレーム4コードです:
import flash.events.MouseEvent;
ScoreFin.text = points.toString();
btnMenu.addEventListener (MouseEvent.CLICK, retourMenu);
function retourMenu (e:MouseEvent):void{
gotoAndStop(2);
}
編集 OPのコメントによると:
からまでのループで関数,を実行すると、正しく初期化されないさまざまなレベル ( LVL2
, LVL3
, ) があります。LVL4
lvl2
lvl3
lvl4
frame 3
line 64 to 110
配列を作成する代わりに、これは最初の 5 つの列のみを作成し、残りは作成しません。