Snow show on YouTube in animate cc canvas.
Hello everyone on the forum.
I saw a very nice show on youtube.
Here is the link.
https://www.youtube.com/watch?v=4p9etJ5GHS0
Maybe someone will explain to me why this code does not work for me.
Snow appears on the stage, but everything stands still.
There is no error in the console.
Here's the code.
var sh = stage.canvas.height*2;
var sw = stage.canvas.width*2;
var snowcontainer = new createjs.Container();
snowcontainer.regX = sw/2;
this.addChild(snowcontainer);
function randomize(min, max) {
return (Math.random() * max) + min; //return Math.round(Math.random() * max) + min;
}
createjs.Ticker.on("tick", snowfall);
function snowfall(e) {
for (var i = snowcontainer.numchildren-1; i >=0; i--){
var s = snowcontainer.getChildAt(i);
s.y += s.speed;
if (s.y > sh+20) {
s.y = randomize(-500, sh);
}
}
}
function snowstrom(sfc) {
for (var i = sfc; i >= 0; i--) {
var sf = new lib.snowflake();
sf.x = randomize(0, sw);
sf.y = randomize(-500, sh);
sf.alpha = randomize(0.5, 0.9);
sf.scaleX = randomize(0.5, 0.9);
sf.scaleY = sf.scaleX;
sf.speed = randomize(1, 8);
snowcontainer.addChild(sf);
}
}
snowstrom(1000);
Regards
