查看: 2919|回复: 0
|
Flash拼图游戏问题
[复制链接]
|
|
我刚刚拿朋友的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);
|
|
|
|
|
|
|
| |
本周最热论坛帖子
|