Where exactly in this fiddle: (http://jsfiddle.net/wXs9J/) is "sprite" defined? I'm using the same type of animation in my own program but I get the line: "Uncaught TypeError: Cannot read property 'stateAnimations' of undefined" at the lines:
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
);
}
Thank you in advance