ippa/jaws — Issue #25: method 'saved' of undefined
Author: krazyjakee
Created: 2012-01-10 03:53:02+00:00
State: open

```javascript
var bubbles = new _bubbles();

$(document).ready(function() {
var context = $('#canvas')[0].getContext("2d");
jaws.assets.add(["img/red-bubble.png","img/yellow-bubble.png","img/blue-bubble.png","img/purple-bubble.png","img/green-bubble.png","img/black-bubble.png"]);
jaws.start(GameState);
});

function GameState() {
this.setup = function(){
bubbles.loadAllAnimations();
bubble_spritelist = jaws.SpriteList();
bubble_spritelist.push(bubbles.red.sprite);
}
this.update = function() {
bubbles.red.sprite.setImage(bubbles.red.animation.next());
}
this.draw = function() {
jaws.clear();
bubble_spritelist.draw();
}
}

function _bubbles(){
this.red = { sprite: new jaws.Sprite({ x:0, y:0 }), animation: [] };
this.yellow = { sprite: new jaws.Sprite({ x:0, y:0 }), animation: [] };
this.blue = { sprite: new jaws.Sprite({ x:0, y:0 }), animation: [] };
this.green = { sprite: new jaws.Sprite({ x:0, y:0 }), animation: [] };
this.purple = { sprite: new jaws.Sprite({ x:0, y:0 }), animation: [] };
this.black = { sprite: new jaws.Sprite({ x:0, y:0 }), animation: [] };
}

_bubbles.prototype.loadAllAnimations = function(){
bubbles.red.animation = bubbles.loadAnimation("red");;
bubbles.yellow.animation = bubbles.loadAnimation("yellow");
bubbles.blue.animation = bubbles.loadAnimation("blue");
bubbles.green.animation = bubbles.loadAnimation("green");
bubbles.purple.animation = bubbles.loadAnimation("purple");
bubbles.black.animation = bubbles.loadAnimation("black");
}
_bubbles.prototype.loadAnimation = function(color){
return new jaws.Animation({sprite_sheet: "img/"+color+"-bubble.png", frame_size: [40,40], frame_duration: 100});
}
```