• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Snow show on YouTube in animate cc canvas.

Community Beginner ,
Jun 16, 2022 Jun 16, 2022

Copy link to clipboard

Copied

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

Views

109

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 17, 2022 Jun 17, 2022

Copy link to clipboard

Copied

Hi.

 

It's because you wrote numchildren (with lowercase c). The correct is to write numChildren (with a capital C).

 

So instead of:

for (var i = snowcontainer.numchildren - 1; i >= 0; i--)

 

It must be:

for (var i = snowcontainer.numChildren - 1; i >= 0; i--)

 

I hope it helps.

 

Regards,

JC

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 17, 2022 Jun 17, 2022

Copy link to clipboard

Copied

Welcome back

Thank you very much, it works.
Man learns all his life.
Thank you again and best regards.

Jan

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 17, 2022 Jun 17, 2022

Copy link to clipboard

Copied

LATEST

You're welcome.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines