我正在尝试使用 paper.js 制作游戏,但有些东西不起作用,所以我已经简化了一些事情并且......不再工作了。
我尝试使用已创建命名空间的 paper.js 进行制作,paperscript但调试起来太难了,所以我尝试直接使用 javascript。
即使使用超级简单的代码在浏览器中移动一个球......它也不起作用。
这是我的代码:
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Bouncing ball</title>
    <link rel="stylesheet" href="../css/style.css">
    <script type="text/javascript" src="../../lib/paper.js"></script>
    <script type="text/javascript">
        var ball;
        function game(_view) {
            console.log("game!");
            ball = new Ball();
            this.view = _view;
            console.log(ball);
        }
        paper.install(window);
        window.onload = function() {
            var canvas = document.getElementById('canvas');
            paper.setup(canvas);
            view.onFrame = onFrame;
            game(view);
        }
        var Ball = Base.extend({
            initialize: function() {
                this.position = new Point(100, 100);
                this.velocity = new Point(3, 0);
                this.path = new Path.Circle(location, 25);
                this.path.strokeColor = 'black';
                this.path.fillColor = 'black';
            },
            iterate: function() {
                this.position += this.velocity;
                this.path.position = this.position;
                return this;
            }
        });
        function onFrame(event) {
            ball.iterate();
            //console.log(ball);
        };
    </script>
</head>
<body>
    <canvas id="canvas" resize></canvas>
</body>
</html>
我不断收到此错误:
未捕获的类型错误:无法调用未定义的方法“迭代”