Friday, 13 January 2012

13/01/12

Today I spent time catching up on the work I missed in yesterday's lesson due to absence- this involved attempting to fix the coding problems I had faced in my previous lesson last Thursday. The codes on my 'finish' button could not determine when all the right variables where touching the correct baskets and moved forward onto the next page regardless of how many right eggs where placed correctly. Therefore my teacher suggested that I changed the count up function to a count down, giving the children a set time to complete the task and scoring them based on how many eggs they placed correctly in a set amount of time; in this case 60 seconds. I therefore changed the counter code to the following;
timer = 60;
countdown = function(){
timer--;
if(timer==0){
clearInterval(countdownInterval);
}
}

countdownInterval = setInterval(countdown,1000);


This code meant that the function of the dynamic text variable would be to count down from 60 at a rate of 1 second per interval, giving students a one minute period in which they could complete the task. My next challenge was to place a code onto the timer that allowed the page to move forward on to another scene once the timer hit '0', however attempts I made using the If function would not work, and the page remained on 0 despite codes telling it to move on.

I finally managed to find a code that worked; it counted down from 60 seconds and on 0 it cleared the Interval and moved on to the scoring page swiftly. This was achieved through placing the following code:
var duration:Number = 60000;
var yourInterval:Number = setInterval(doSomething, duration);
function doSomething():Void
{
    gotoAndPlay("Score Page", 1);
    clearInterval(yourInterval);
    
}
on to another layer in my scene- this told my project to move on to my score page once 60 seconds had elapsed; although it was not connected to the timer, which would not allow me to place an If(timer==0) go to and stop function, it still works as intended.
I then moved on to the last problem until my project was complete- this was the scoring system. I was now not using the timer to create a score but created a variable which increased every time an egg was placed on to the right basket, and after one minute this total score was displayed on the score page. I created a variable known as 'blue' and placed the code:
if (blue1.hitTest(bluebasket)) {
  blue+=1;
regarding all possible instances, which enabled the computer to score the users based on how many eggs they had placed in the right position, and display this amount on the score page. I have run out of time to fully fix this problem and will use Tuesday's lesson to fully create a solution that will accurately count up a score based on the position of eggs on the page.

No comments:

Post a Comment