PaperJs 报错不稳定
PaperJs errors are not understable
Paper.js 遇到很多问题。在 Udemy 上参加 Colt Steele 的 Web 开发人员训练营。我在第 19 节。目前正在尝试制作 Patatap 克隆。
<!DOCTYPE html>
<html>
<head>
<title>Colors Sound</title>
<link rel="stylesheet" type="text/css" href="assets/css/index.css">
<script type="text/javascript" src="assets/js/lib/paper-full.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/howler/2.0.9/howler.core.min.js"></script>
<script type="text/paperscript" canvas="myCanvas">
var newCircle = new Path.Circle(new Point(50, 50),50);
newCircle.fillColor = "red";
var keyData = {
a: { sound = new Howl({
src: [assets/sounds/clay.mp3]
}),
color: 'red'
}
}
function onKeyDown(e){
if(keyData[e.key]){
var maxPoint = new Point(max.width.size, max.height.size);
var randomPoint = Point.Random();
var point = maxPoint * randomPoint ;
var circle = new Path.Circle(point, 50);
circle.fillColor = keyData[e.key].color;
keyDAta[e.key].sound.play();
}
}
</script>
</head>
<body>
<canvas id="myCanvas" resize></canvas>
</body>
</html>
这些是 Chrome 控制台中的错误:
Uncaught SyntaxError: Unexpected token (5:14)
at raise (paper-full.js:14884)
at unexpected (paper-full.js:15524)
at parseObj (paper-full.js:16002)
at parseExprAtom (paper-full.js:15957)
at parseExprSubscripts (paper-full.js:15888)
at parseMaybeUnary (paper-full.js:15874)
at parseExprOps (paper-full.js:15840)
at parseMaybeConditional (paper-full.js:15827)
at parseMaybeAssign (paper-full.js:15813)
at parseExpression (paper-full.js:15802)
首先,您可以使用 diffchecker 与 Colt 的代码对照您自己的代码,从而非常轻松地检查错误。
其次,乍一看,你的错误在
sound = new Howl
应该是
sound: new Howl
当您使用对象时,这些对象使用 key/value 对
Paper.js 遇到很多问题。在 Udemy 上参加 Colt Steele 的 Web 开发人员训练营。我在第 19 节。目前正在尝试制作 Patatap 克隆。
<!DOCTYPE html>
<html>
<head>
<title>Colors Sound</title>
<link rel="stylesheet" type="text/css" href="assets/css/index.css">
<script type="text/javascript" src="assets/js/lib/paper-full.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/howler/2.0.9/howler.core.min.js"></script>
<script type="text/paperscript" canvas="myCanvas">
var newCircle = new Path.Circle(new Point(50, 50),50);
newCircle.fillColor = "red";
var keyData = {
a: { sound = new Howl({
src: [assets/sounds/clay.mp3]
}),
color: 'red'
}
}
function onKeyDown(e){
if(keyData[e.key]){
var maxPoint = new Point(max.width.size, max.height.size);
var randomPoint = Point.Random();
var point = maxPoint * randomPoint ;
var circle = new Path.Circle(point, 50);
circle.fillColor = keyData[e.key].color;
keyDAta[e.key].sound.play();
}
}
</script>
</head>
<body>
<canvas id="myCanvas" resize></canvas>
</body>
</html>
这些是 Chrome 控制台中的错误:
Uncaught SyntaxError: Unexpected token (5:14)
at raise (paper-full.js:14884)
at unexpected (paper-full.js:15524)
at parseObj (paper-full.js:16002)
at parseExprAtom (paper-full.js:15957)
at parseExprSubscripts (paper-full.js:15888)
at parseMaybeUnary (paper-full.js:15874)
at parseExprOps (paper-full.js:15840)
at parseMaybeConditional (paper-full.js:15827)
at parseMaybeAssign (paper-full.js:15813)
at parseExpression (paper-full.js:15802)
首先,您可以使用 diffchecker 与 Colt 的代码对照您自己的代码,从而非常轻松地检查错误。
其次,乍一看,你的错误在
sound = new Howl
应该是
sound: new Howl
当您使用对象时,这些对象使用 key/value 对