问题描述
我做了一个分数计数器,如果玩家开始1级,如果赢了,计数器正在继续工作到下一个级别(Level = frame),到目前为止还没有任何问题。但是当玩家有选择从菜单级别和开始级别2,计数器不工作。级别2从第116帧开始。我得到一个 NaN 错误。 p>
我写这样一个代码scrore frame 1
var Scorecounter:Number = 0;
和Score_t1是一个动态文本。在第一帧使用计数器代码
函数checkButtonsone():void
{
if(fisoneclicked21&&fistwoclicked)
{
Scorecounter = Scorecounter + 10;
Score_t1.text =(Scorecounter).toString();
acmessage.visible = true;
acmessage.play();
$ b $ gotoAndPlay(116); // LEVEL 2
}
}
$
$ b $ p $函数checkButtonponele2():void
{
if (fish1clickedlevel2&& fishtwoclickedlevel2&&
fishthreeclickedleveltwo)
{
Scorecounter = Scorecounter + 10;
Score_t1.text =(Scorecounter).toString();
famessage.visible = true;
famessage.play();
$ b我没有使用两个关键帧beetwen.So (285)
嗯,我不知道为什么时间线脚本不能为你工作你可能想跟踪Scorecounter),但我可以建议一个全局变量的解决方案。创建一个类文件ScoreHolder.as,并把它放在与* .fla相同的文件夹中。
$ b $ pre $ $ $ $ $ $ $ $ $ $ $ {
public class ScoreHolder
{
static public var score:Number = 0;
然后将其导入任何你想要访问的帧得分值:
import ScoreHolder;
函数checkButtonsone():void
{
if(fisoneclicked21&& fistwoclicked)
{
ScoreHolder.score + = 10;
Score_t1.text = ScoreHolder.score.toString();
acmessage.visible = true;
acmessage.play();
gotoAndPlay(116); // LEVEL 2
}
}
I made a score counter and if has player start level 1 and if has win,counter is keep working to next level.( Level = frame ) it's not exist any issue so far.
But when player has choice to level from menu and start level 2,counter is not work.Level 2 start from to frame 116.I get a "NaN" error.
I write a code like this scrore frame 1
var Scorecounter:Number = 0;
And Score_t1 it's a dynamic text.Use counter code on frame one
function checkButtonsone():void
{
if(fisoneclicked21 && fistwoclicked)
{
Scorecounter = Scorecounter + 10;
Score_t1.text = (Scorecounter).toString();
acmessage.visible = true;
acmessage.play();
gotoAndPlay(116);//LEVEL 2
}
}
and on level 2
function checkButtonponelev2():void
{
if(fish1clickedleveltwo && fishtwoclickedleveltwo &&
fishthreeclickedleveltwo)
{
Scorecounter = Scorecounter + 10;
Score_t1.text = (Scorecounter).toString();
famessage.visible = true;
famessage.play();
}
}
I'm not using keyframe beetwen two levels.So score frame continue until last frame.(285)
Well, I've no idea why timeline scripting not working for you (you might want to trace Scorecounter if it inits though), but I can suggest a "global" variable solution. Create a class file ScoreHolder.as and put it in the same folder as your *.fla
package
{
public class ScoreHolder
{
static public var score:Number = 0;
}
}
Then import it in any frame where you want to access the score value:
import ScoreHolder;
function checkButtonsone():void
{
if (fisoneclicked21 && fistwoclicked)
{
ScoreHolder.score += 10;
Score_t1.text = ScoreHolder.score.toString();
acmessage.visible = true;
acmessage.play();
gotoAndPlay(116);//LEVEL 2
}
}
这篇关于我得到一个“南”当玩家从菜单中选择等级时,分数计数器上的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!