佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

查看: 2918|回复: 0

Flash拼图游戏问题

[复制链接]
发表于 18-5-2013 10:40 PM | 显示全部楼层 |阅读模式
我刚刚拿朋友的flash游戏拼图来改,朋友的是12张,我做的是9张,比较大,可是test movie时拼图不会自动散,也移不到,不知道是那个coding的问题,请各位大大帮忙送上意见一下...我的原本16张拼图的coding如下....

//declare piece of the puzzle picture
var pics = 16;
//declare pics as count
var count = pics;
//radius to stick the picture is around 300
radius = 300;
//loop the pics
for (var i = 1; i <= pics; i++)
{
        //Establish a reference to the target object
        var mc = _root["b" + i];
        mc.removeMovieClip();
        //Record the initial position
        mc.origX = mc._x;
        mc.origY = mc._y;
       
        //random all the pics and place around the stage
        mc._x = Math.floor (Math.random () * 350) + 150;
        mc._y = Math.floor (Math.random () * 350) + 150;
       
        //To add operation code for Blocks
        mc.onPress = function ()
        {
                this.swapDepths (_root.getNextHighestDepth ());
                startDrag (this);
        }
       
        mc.onRelease = function ()
        {
                stopDrag ();
                //Stop the drag, the position detection, if less than a certain range, then directly reach the destination position.
                if ((this._x - this.origX) * (this._x - this.origX) + (this._y - this.origY) * (this._y - this.origY) <= radius)
                {
                        this._x = this.origX;
                        this._y = this.origY;
                       
                        //he delete block the operation of code, avoid the user move again the tiles in place
                        delete this.onPress;
                        delete this.onRelease;
                        delete this.onReleaseOutside;
                       
                       
                        //Placed in the picture below, to avoid overwriting other unfinished picture.
                        this.swapDepths (-count);
                        //
                        count--;
                        if (count == 0)
                        {
                               
                                gotoAndStop("Scene6", "ss1");
                        }
                }
        };
       
        //Decrease in the statistical value of the game progress, reduced to 0, it indicates that the game is completed.
        mc.onReleaseOutside = function ()
        {
                stopDrag ();
                if ((this._x - this.origX) * (this._x - this.origX) + (this._y - this.origY) * (this._y - this.origY) <= radius)
                {
                        this._x = this.origX;
                        this._y = this.origY;
                        delete this.onPress;
                        delete this.onRelease;
                        delete this.onReleaseOutside;
                        this.swapDepths (-count);
                        count--;
                        if (count == 0)
                        {
                                 
                                gotoAndStop("Scene6", "ss1");
                               
                        }
                }
        };
}

time=120;//time to game over
        countdown = function()
        {
        time--;
        if(time==0)
        {
                for (i = 1; i <= pics; i++)
                {
                        mc = _root["b" + i];
                        mc.removeMovieClip();//remove the movie clip when time up
                        //removeMovieClip(_root["a" + i]);
                }
                clearInterval(countdownInterval);
                /*pics_mc.swapDepths (0);
                pics_mc.removeMovieClip(this);*/
                gotoAndStop("Scene 5", "gg1");
        }
        else if(count==0)
        {
               
                clearInterval(countdownInterval);
        }
        }
countdownInterval = setInterval(countdown,1000);

回复

使用道具 举报

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

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


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

GMT+8, 28-3-2024 05:12 PM , Processed in 0.075841 second(s), 28 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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