In my spelling game, I have arrays of words that is added to a text field one at a time (through a loop). They are also split into letters so that the player can click on a corresponding letter tile to copy the word. The active letter would be 100% visible (alpha setting )and the other letters would be set to 80%.
Splitting each word works well it you just want the entire word broken into individual letters, BUT I want my game to be phonics based - so sometimes the sound in a word will have more than one letter e.g. for the word "elephant" the array would be: activeWord:Array = ["e","l","e","ph","a","nt"] and there would of cause be letter tiles with the sound -ph- and -nt- on them to click on too.
I guess this is where arrays within arrays gets the job done? I have 10 words per level and 30 levels. I will break each word into it's sounds and hardcode each word like I did elephant above.
How do I rewrite the loop below to accomodate the 10 word loop within a level. After each level I want a score to appear with the option to click next for the next level.
public var wordsL1:Array = ["elephant","has","of","off","on","not","got","in","is","it"];
private var tf:TextField;
public var letterArray:LetterArray;
public var tileTimer = new Timer(500,384);
// ***constructor code
public function WordArray(_tf:TextField)
{
tf = _tf;
nextWordF();
//**Run letter Tiles Start**//
letterArray = new LetterArray();
addChild(letterArray);
tileTimer.addEventListener(TimerEvent.TIMER, gameLoop);
tileTimer.start();
}
public function gameLoop(timerEvent:TimerEvent):void
{
trace("Tile Timer Started");
letterArray.gameLoop();
}
//**end**//
function nextWordF():void
{
if(wordsL1.length>0)
{
activeWordF();
populateMyWordBox();
}
else
{
//quiz is complete
}
}
private function activeWordF():void
{
activeWordArray = wordsL1.shift().split("");
// this array needs to be passed to the class that checks which letters are clicked (or used in this class if that's where the clicked letters are handled) so the clicked letters can be compared to activeWordArray's elements.
// when the clicked letters are completed for this word, call nextWordF().
}