我是一名大学生,目前正在研究动作脚本3 Flash游戏编码而且我已经 遇到标题中的两个编码问题。 1023和1021。
我查看了多个论坛和帖子(甚至在这里),以找到解决方案,但一切 我试着似乎根本没有工作。我正在撕扯我的头发,我只是想要它 上班。如果有人能帮助我指出什么是错的,我会非常感激 赞赏它!
var loader:URLLoader;
var allWords:Array;
var thisWord:String;
var textContainer:MovieClip
var textFields:Array;
var textStyle:TextFormat;
var underline:MovieClip;
var numCorrect:uint;
var totalLetters:uint;
var misses:uint;
var missiesToLose:uint;
function initializeGame():void
{
loader = new URLLoader();
allWords = new Array();
textContainer = new MovieClip();
textFields = new Array()
textStyle = new TextFormat();
textStyle.font = "Courier New";
textStyle.size = 48;
textStyle.bold = true;
guesses_txt.text = "";
numCorrect = 0;
textContainer.y = 320.30;
addChild(textContainer);
loader.load(new URLRequest("words.txt"));
loader.addEventListener(Event.COMPLETE, textLoaded);
guess_btn.addEventListener(MouseEvent.CLICK, guess);
}
function textLoaded(event:Event):void
{
var tempText:TextField;
var stringOfWords:String = event.target.data;
allWords = stringOfWords.split(",");
thisWord = allWords[7];
totalLetters = thisWord.length;
//characters loop
for(var i:uint = 0; i < thisWord.length; i++)
{
tempText = new TextField();
tempText.defaultTextFormat = textStyle; //font type
tempText.name = "textField" + i;
tempText.width = 48;
tempText.x = i * tempText.width;
tempText.selectable = false;
textContainer.addChild(tempText);
textFields.push(tempText);
if(thisWord.charAt(i) != " ")
{
underline = new Underline();
underline.x = tempText.x + tempText.width /3;
underline.y = tempText.y + tempText.height/2 + 5;
textContainer.addChild(underline);
}
}
textContainer.x = stage.stageWidth /2 - textContainer.width/2;
}
function guess(Event:MouseEvent):void
{
var wordLC:String = thisWord.toLowerCase();
if(guess_txt.text != "")
{
if(wordLC.indexOf(guess_txt.text) != -1)
{
for(var i:uint = 0; i < textFields.length; i++)
{
if(wordLC.charAt(i) == guess_txt.text)
{
textFields[i].text = thisWord.charAt(i);
numCorrect ++;
if(numCorrect >= totalLetters)
{
gotoAndPlay(2);
}
}
}
}
else if(guesses_txt.text == "")
{
guesses_txt.appendText(guess_txt.text);
}
else
{
guesses_txt.appendText("," + guess_txt.text)
}
}
guess_txt.text = "";
}
initializeGame();
答案 0 :(得分:0)
我认为代码是关键帧。我没有做太多的关键帧编程(出于显而易见的原因),但如果第二次播放该关键帧,则会再次运行整个代码,并且可能会发生变量和函数的重复。检查您的movieclip是否第二次击中该特定关键帧。如果是,您可以通过初始化开关(您希望的任何形状或形式)或在课程级别上的图书馆课程来解决这个问题。