我最近为此开发了一台老虎机。我敢肯定有很多方法可以做到这一点,但这是我做的方式。这必须为每个卷轴完成。
在您的 blitmask 中通常可以看到三个符号。如果您的 blitmask 高一个符号,那么此方法将为您提供可见符号
首先声明一个变量以跟踪中心符号。
我定位了我的条带,使第三个符号位于 blitmask 窗口的中心,记住这不是索引。
基本上你知道它会降落在哪里,所以你可以在它降落之前找出符号是什么。
var REEL1:Number = 3;
function spin(event:MouseEvent):void
{
var newNumber:Number = (randomNumber(1, 10)) ;
//call function to find the symbol to land
REEL1 = GetReelPosition(REEL1, newNumber);
//work out the amount to tween. Random number * symbol height + strip length
//if you want a longer spin add more strip lengths
newNumber = (newNumber * 100) + 1000;
var myTimeline:TimelineMax = new TimelineMax();
myTimeline.append(new TweenLite(Strip1, 2, {y:String(newNumber)}));
//get target symbol as movieclip
var currentTile:MovieClip = Strip1.getChildAt(REEL1-1) as MovieClip;
//if you have export for actionscript, this will tell what the object is
trace(String(currentTile));
}
创建条带时,从图像中制作符号,导出为动作脚本,然后从上到下添加到条带中。如果更改符号,则必须再次从上到下删除并粘贴。该索引反映了添加符号的顺序。
function GetReelPosition(reel:Number,num:Number):Number
{
reel = reel - num;
switch(reel)
{
//if symbol is the first number on the strip and random
//number = 1 (1-1) then the centre symbol is the last on the strip
case 0:
reel = 10;
break;
//if symbol is the first number on the strip and random
//number = 10 (1-10) then the centre symbol is the first on the strip
case 1:
case -9:
reel = 1;
break;
case 2:
case -8:
reel = 2;
break;
case 3:
case -7:
reel = 3;
break;
case 4:
case -6:
reel = 4;
break;
case 5:
case -5:
reel = 5;
break;
case 6:
case -4:
reel = 6;
break;
case 7:
case -3:
reel = 7;
break;
case 8:
case -2:
reel = 8;
break;
//case 9, -1:
case 9:
case -1:
reel = 9;
break;
}
return reel;
}
我更新了开关代码。案例 9,-1:不可靠。我不确定我选择了哪种语言。
这是我的第一个 Flash 项目,我很快就完成了这台老虎机。我确信有更好的方法来做到这一点。看看我的插槽?
http://rcras.com/pokies/funnyfarm