佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

查看: 821|回复: 3

有关frame的问题..

[复制链接]
发表于 8-3-2006 11:48 PM | 显示全部楼层 |阅读模式
这里有一个小问题。。
我用几个array来design maze在frame 1。。。然后,randomly select a array and pass the array to frame 5 which contain code to generate the maze.
我的问题是为什么当我用button "gotoAndPlay(2)" (因为要refresh maze)时, 那个maze就不能display了。。
我想要的是refresh那个maze,可是好像当"gotoAndPlay(2)"时,,那个array的就不见了。。
我不能"gotoAndPlay(1)", 因为我要拿回同样的maze..所以是refresh maze 的意思..

那是不是代表我在"gotoAndPlay(2)"时,在fram 1 里拿的array 就会不在??有没有什么办法??

谢谢回答..
回复

使用道具 举报


ADVERTISEMENT

发表于 9-3-2006 12:35 AM | 显示全部楼层
不清楚你說的情況,最好是把文件上傳。
回复

使用道具 举报

发表于 12-3-2006 01:16 AM | 显示全部楼层
什么是array啊??
回复

使用道具 举报

发表于 12-3-2006 03:31 AM | 显示全部楼层
原帖由 yong2212 于 8-3-2006 11:48 PM 发表
这里有一个小问题。。
我用几个array来design maze在frame 1。。。然后,randomly select a array and pass the array to frame 5 which contain code to generate the maze.
我的问题是为什么当我用button &qu ...






//--------- frame 1 --------

var line = new Array();
line[0] = new Array(
                 [1,2,1,1,1,1,1,1,1,1],
                 [1,0,1,0,0,0,0,0,0,1],
                 [1,0,1,0,1,0,1,1,0,1],
                 [1,0,1,1,1,0,1,1,0,1],
                 [1,0,0,0,0,0,0,1,0,1],
                 [1,0,1,0,1,1,1,1,0,1],
                 [1,0,1,0,0,0,1,1,0,1],
                 [1,0,1,1,1,0,1,1,0,1],
                 [1,0,0,0,1,0,1,1,0,3],
                 [1,1,1,1,1,1,1,1,1,1]
                 );

line[1] = new Array(
                 [1,1,1,1,1,1,1,1,1,1],
                 [1,0,1,0,0,0,0,0,0,1],
                 [1,0,1,0,1,0,1,1,0,1],
                 [1,0,1,1,1,0,1,1,0,1],
                 [1,2,0,0,0,0,0,1,0,1],
                 [1,0,1,0,1,1,1,1,0,1],
                 [1,0,1,0,0,0,1,1,0,1],
                 [1,0,1,1,1,0,1,1,0,1],
                 [1,0,0,0,1,0,1,1,0,3],
                 [1,1,1,1,1,1,1,1,1,1]
                 );

var rand = line[random(line.length)];









//-------------- frame 5 ----------------
//set the size of the image
var size:Number=20;
var surface:MovieClip = this.createEmptyMovieClip("maze",1);

//allocate the maze position
surface._x = 60;
surface._y = 90;
var mazewall:MovieClip = surface.createEmptyMovieClip("wall",2);

//attachmovie function
function attach(id,x,y)
{
        var depth:Number = mazewall.getNextHighestDepth();
        var box:MovieClip = mazewall.attachMovie(id,"b" + depth,depth);
        box._x = x * size;
        box._y = y * size;
}


//use to hold startpoint and endpoint
var startPoint:Object = new Object;
var endPoint:Object = new Object;
var playerPoint:Object = new Object;
var newRand = new Array();

//create wall,startpoint,endpoint and player
for (y=0;y<rand.length;y++){
                newRand[y] = new Array();
        for (x=0;x<rand[y].length;x++){
                // rebuild the map data, so that we can use in solve:method
                var type:Number = rand[y][x];
                var o:Object = new Object();
                o.type = type;
                o.x = x;
                o.y = y;
                o.visited = false;
                newRand[y][x] = o;
                // checking the cell type and draw them
                switch(type)
                {
                        case 0:
                        break;
                        
                        case 1:
                        //create walls
                        attach("box",x,y);
                        break;
                        
                        case 2:
                        //create startpoint and player
                        attach("startpoint",x,y);
                        var p:MovieClip = surface.attachMovie("player","player2",surface.getNextHighestDepth());
                        p._x = x*size;
                        p._y = y*size;
                        playerPoint        .x = x;
                        playerPoint        .y = y;
                        playerPoint        .mc = p;
                        startPoint = o;
                        break;
                        
                        case 3:
                        //create endpoint
                        attach("endpoint",x,y);
                        endPoint = o;
                        break;
                }
        }
}

//Control "player"
function onKeyDown(){
        var x:Number = playerPoint.x;
        var y:Number = playerPoint.y;
        //key control
        switch (Key.getCode())
        {
                case Key.UP:
                y = y - 1;
                break;
               
                case Key.DOWN:
                y = y + 1;
                break;
               
                case Key.LEFT:
                x = x - 1;
                break;
               
                case Key.RIGHT:
                x = x + 1;
                break;
        }
        //test the road can run or not
        var road = newRand[y][x].type;
        if(road != 1 && road != undefined)
        {
                playerPoint.mc._x = x * size;
                playerPoint.mc._y = y * size;
                playerPoint.x = x;
                playerPoint.y = y;
        }
        //to the endpoint
        if(road == 3)
        {
                trace("Exit");
                //remove movieclip
                removeMovieClip(surface);
                gotoAndPlay(2);
        }
}

//receive key control signal
Key.addListener(this);

//create a button call refreshBtn on stage
refreshBtn.onRelease = function() {
        gotoAndPlay(2);
}
stop();
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 22-9-2024 01:33 AM , Processed in 0.099719 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表