The link below is a tutorial on how to create falling snow in Flash by using ActionScript (there is no need for tweening each snowflake) Each flake will be scaled to its speed. They have also added randomization so flakes don’t fall in same direction. I could use this tutorial and interpret the ideas and principles behind it to incorporate it into my own game, for instance when the healthy and unhealthy foods will drop from the top of the screen.
http://www.tutorialized.com/view/tutorial/Let-Is-Snow-in-Flash-MX/10617
There is information on this tutorial on how to create the snowflake, however I am going to look at the code and interpret the way they have used this. The code is shown below:
width = 550;
height = 400;
total = 200;
for (var t = 0; t != total; t++) {
var mc = _root.attachMovie(“snowflake”, “snowflake”+t, _root.getNextHighestDepth());
mc._x = (Math.random()*(width+20))-10;
mc._y = (Math.random()*(height+20))-10;
mc.yspeed = (Math.random()*1.75)+0.25;
mc.speed = (Math.random()*3)+2;
mc._xscale = mc._yscale=(mc.speed+mc.yspeed)*10;
mc.onEnterFrame = function() {
var angle = Math.atan2(_root._xmouse-(width/2), _root._ymouse)+1.5707963267949;
this._y += Math.sin(angle)*this.speed+this.yspeed;
this._x += Math.cos(angle)*this.speed;
if (this._x>width+10) {
this._x = -10;
} else if (this._x<0-10) {
this._x = width+10;
}
if (this._y>height+10) {
this._y = -10;
} else if (this._y<0-10) {
this._y = height+10;
}
};
}
When using this code I would have to remember to change the height, width and variables accordingly to my game. The total part means the total number of snowflakes that will appear.
Attach movie is adding in the movie of what you will create before the code and then it is putting in the depth of the code.
The random code is where the randomization of where the snowflake appears, here you will place the movie clip onto a random point on the stage and the code will pick any number between 0 and 1. The X (vertical) and Y (horizontal) speed variables control the speed which the movie clip travels.
The onEnterFrame code moves the snowflake. This calculates the angle of the mouse. The movie clip moves along the y axis and along the x axis through multiplying angle of mouse and speed together. There are a number of different tutorials I will look at which teach how to learn how to create falling snow in Flash. These tutorials are shown on the links below:
http://www.kirupa.com/developer/mx/snow.htm
http://www.sitepoint.com/article/script-falling-snow-effect
I will look at these to understand how they use code in their tutorials.
When using information that others have used to aid me towards my project I need to be careful with the plagiarism issue. I will have to deconstruct the code so that I understand what it does and incorporate it into the principles I use to make my game. I cannot just pass somebody’s work as my own and I will have to correctly reference all work that I have used when I hand in my assignment.