Simplify the superclass-super-calling jazz.
Chris Pressey
10 years ago
42 | 42 | Floater = function(proto) { |
43 | 43 | this.init = function(cfg) { |
44 | 44 | // call superclass'es init() method |
45 | proto.init.apply(this, [cfg]); | |
45 | Floater.prototype.init.apply(this, [cfg]); | |
46 | 46 | this.isClickable = true; |
47 | 47 | this.counter = 0; |
48 | 48 | this.rate = 0.07; |
170 | 170 | }; |
171 | 171 | |
172 | 172 | this.init = function(c) { |
173 | //Floater.prototype = new yoob.Sprite(); | |
174 | var proto = new yoob.Sprite(); | |
175 | Floater.prototype = proto; | |
173 | Floater.prototype = new yoob.Sprite(); | |
176 | 174 | |
177 | 175 | canvas = c; |
178 | 176 | ctx = canvas.getContext('2d'); |
184 | 182 | |
185 | 183 | var closeness = 5; |
186 | 184 | for (var i = 1; i < 30; i++) { |
187 | var f = new Floater(proto); | |
185 | var f = new Floater(); | |
188 | 186 | var w = closeness; |
189 | 187 | var x = Math.random() * (canvas.width - w * 2); |
190 | 188 | var y = Math.random() * (canvas.height - w * 2); |