我正在尝试从一本关于使用 JS Canvas 制作动画的书中的示例。
其中一个示例使用以下调用从原型创建精灵:
sprite = new Sprite('runner',
new SpriteSheetPainter(runnerCells),
[ runInPlace, moveLeftToRight ]);
“runnerCells”是对 JS 数组的引用,它决定了动画每个单元格在 spritesheet 上的位置。我不明白如何以一种允许我将“runnerCells”更改为不同数组以创建不同动画的方式访问“sprite”变量。有什么建议么?
您可以在此处查看完整示例:http: //corehtml5canvas.com/code-live/ch06/example-6.9/example.html
相关的 JS 库位于此处: http ://corehtml5canvas.com/code-live/ch06/example-6.9/example.js