From 44c899dbdedfaa445b5e4c999178142de9e75a17 Mon Sep 17 00:00:00 2001 From: Oskari Timperi Date: Fri, 5 Aug 2011 08:29:06 +0300 Subject: Modify Gag to use ResourceMan --- Gag.js | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'Gag.js') diff --git a/Gag.js b/Gag.js index 2fa4754..ff8d31c 100644 --- a/Gag.js +++ b/Gag.js @@ -5,15 +5,13 @@ var Gag = function(cat, x, y, dir) { } var p = Gag.prototype = new Container(); - Gag.initialize = function() { - Gag.img = new Image(); - Gag.img.onload = function() { - Gag.gfx = new Bitmap(Gag.img); - } - Gag.img.src = "gfx/catgag.png"; - } - Gag.initialize(); - Gag.count = 0; +Gag.count = 0; +Gag.img = null; + +Gag.initialize = function() { + Gag.img = Game.resMan.get("catgag"); + Gag.gfx = new Bitmap(Gag.img); +} p.escaped = false; p.dir = 0; @@ -31,7 +29,7 @@ var p = Gag.prototype = new Container(); this.dir = dir; this.cat = cat; - this.gfx = new Bitmap(Gag.img); + this.gfx = Gag.gfx.clone(); this.addChild(this.gfx); cat.getStage().addChild(this); -- cgit v1.2.3