Saturday, 29 January 2011

Adding some outside influence

I remembered the lecture from last week where we were shown how to get the computers' time and/or date, which would be very useful to include within my game, to change something depending on the time. I decided then to use this idea to change the background to a day/night themed image depending on the time that the computer playign the game is set to.

My initial code was formatted with variables to collect the current time, and then a function with an if function for each hour, to then set the background to day or night (again variables for both backgrounds) which it would change to through the addchild function, to place an image onto the stage through code. This however didn't work, and I doubt it would have worked as I wanted it to. Luckily another iDat student offered some help with a piece of code which would work how I wanted to, so thankfully I was able to use it within my code and it worked great. A big thanks to Joe WljgrsMott!

Here's a quick comparison screenshot to show the time and that it has changed the background image;

No comments:

Post a Comment