这个小提琴到底在哪里:(http://jsfiddle.net/wXs9J/)是“精灵”定义的?我在自己的程序中使用了相同类型的动画,但我得到以下行:“Uncaught TypeError: Cannot read property 'stateAnimations' of undefined”:
function drawSprite(sprite) {
ctx.drawImage(
sprite.stateAnimations[sprite.currentState].tileset.image,
sprite.stateAnimations[sprite.currentState].frames[sprite.stateAnimations[sprite.currentState].currentFrame].split(',')[0] * sprite.stateAnimations[sprite.currentState].tileset.tileWidth,
sprite.stateAnimations[sprite.currentState].frames[sprite.stateAnimations[sprite.currentState].currentFrame].split(',')[1] * sprite.stateAnimations[sprite.currentState].tileset.tileHeight,
sprite.stateAnimations[sprite.currentState].tileset.tileWidth,
sprite.stateAnimations[sprite.currentState].tileset.tileHeight,
Math.round(sprite.positionX),
Math.round(sprite.positionY),
sprite.width,
sprite.height
);
}
先感谢您