p5 找不到变量 masterVolume
p5 can't find variable masterVolume
我added p5.sound.js as instructed,并保证它在正确的地方。我试着打电话:
masterVolume(1.0, 0.05, 0)
它给了我错误。怎么回事?
这是失败代码的完整页面:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width"/>
<title>test</title>
<style>
body {
margin: 0;
-webkit-user-select: none;
}
canvas { display: block; }
.green {
color:#219900;
}
</style>
</head>
<body>
<script src="js/p5.min.js"></script>
<script src="js/p5.sound.min.js"></script>
<script>
masterVolume(1.0, 0.05, 0)
</script>
</body>
</html>
为了调用masterVolume
p5js必须先调用setup
尝试将对 masterVolume 的调用放在将 运行 设置中或设置后的函数中。
function setup() {
// try the call here
masterVolume(1.0, 0.05, 0);
}
function draw(){
// or try the call here or in any p5js method
masterVolume(1.0, 0.05, 0);
}
我added p5.sound.js as instructed,并保证它在正确的地方。我试着打电话:
masterVolume(1.0, 0.05, 0)
它给了我错误。怎么回事?
这是失败代码的完整页面:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width"/>
<title>test</title>
<style>
body {
margin: 0;
-webkit-user-select: none;
}
canvas { display: block; }
.green {
color:#219900;
}
</style>
</head>
<body>
<script src="js/p5.min.js"></script>
<script src="js/p5.sound.min.js"></script>
<script>
masterVolume(1.0, 0.05, 0)
</script>
</body>
</html>
为了调用masterVolume
p5js必须先调用setup
尝试将对 masterVolume 的调用放在将 运行 设置中或设置后的函数中。
function setup() {
// try the call here
masterVolume(1.0, 0.05, 0);
}
function draw(){
// or try the call here or in any p5js method
masterVolume(1.0, 0.05, 0);
}