0

我从 Chrome 收到的错误是: Uncaught TypeError: Cannot read property 'position' of undefined 我不明白为什么我无法访问此路径的位置字段,因为它在文档中明确定义:http: //paperjs.org/reference/path/#位置
这是我的简单代码:

paper.install(window);
var canvas = document.getElementById("letterCanvas");
window.onload = function()
{
    paper.setup("letterCanvas");

function Game(width, height)
{
    this.width = width;
    this.height = height;
    this.tps = 60;
    this.test = new Path.Rectangle(new Point(100,100), [50,100]);
    this.test.strokeColor = "black";
}

Game.prototype.tick = function()
{
    this.test.position = this.test.position.add(5,5);
}

function Activity(game)
{

}

view.onFrame = function()
{
    game.test.rotate(3);
}

var game = new Game(988,644);
__intervalId = window.setInterval(game.tick,1000/game.tps);
view.draw();
}
4

2 回答 2

1

尝试game.tick()代替game.tick

于 2013-08-22T16:27:46.513 回答
0

在窗口上调用的版本 game.tick 中,使用此

__intervalId = window.setInterval(function() { game.tick() } ,1000/game.tps);
于 2013-08-22T16:29:46.830 回答