| OLD | NEW |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 (function() { | 4 (function() { |
| 5 'use strict'; | 5 'use strict'; |
| 6 /** | 6 /** |
| 7 * T-Rex runner. | 7 * T-Rex runner. |
| 8 * @param {string} outerContainerId Outer containing element id. | 8 * @param {string} outerContainerId Outer containing element id. |
| 9 * @param {Object} opt_config | 9 * @param {Object} opt_config |
| 10 * @constructor | 10 * @constructor |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 */ | 284 */ |
| 285 loadImages: function() { | 285 loadImages: function() { |
| 286 if (IS_HIDPI) { | 286 if (IS_HIDPI) { |
| 287 Runner.imageSprite = document.getElementById('offline-resources-2x'); | 287 Runner.imageSprite = document.getElementById('offline-resources-2x'); |
| 288 this.spriteDef = Runner.spriteDefinition.HDPI; | 288 this.spriteDef = Runner.spriteDefinition.HDPI; |
| 289 } else { | 289 } else { |
| 290 Runner.imageSprite = document.getElementById('offline-resources-1x'); | 290 Runner.imageSprite = document.getElementById('offline-resources-1x'); |
| 291 this.spriteDef = Runner.spriteDefinition.LDPI; | 291 this.spriteDef = Runner.spriteDefinition.LDPI; |
| 292 } | 292 } |
| 293 | 293 |
| 294 this.init(); | 294 if(!Runner.imageSprite.complete) { |
| 295 // If the images are not yet loaded, add a listener. |
| 296 Runner.imageSprite.runner = this; |
| 297 |
| 298 Runner.imageSprite.onload = function() { |
| 299 this.runner.init(); |
| 300 } |
| 301 } else { |
| 302 this.init(); |
| 303 } |
| 295 }, | 304 }, |
| 296 | 305 |
| 297 /** | 306 /** |
| 298 * Load and decode base 64 encoded sounds. | 307 * Load and decode base 64 encoded sounds. |
| 299 */ | 308 */ |
| 300 loadSounds: function() { | 309 loadSounds: function() { |
| 301 if (!IS_IOS) { | 310 if (!IS_IOS) { |
| 302 this.audioContext = new AudioContext(); | 311 this.audioContext = new AudioContext(); |
| 303 | 312 |
| 304 var resourceTemplate = | 313 var resourceTemplate = |
| (...skipping 2376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2681 | 2690 |
| 2682 /** | 2691 /** |
| 2683 * Add a new cloud to the horizon. | 2692 * Add a new cloud to the horizon. |
| 2684 */ | 2693 */ |
| 2685 addCloud: function() { | 2694 addCloud: function() { |
| 2686 this.clouds.push(new Cloud(this.canvas, this.spritePos.CLOUD, | 2695 this.clouds.push(new Cloud(this.canvas, this.spritePos.CLOUD, |
| 2687 this.dimensions.WIDTH)); | 2696 this.dimensions.WIDTH)); |
| 2688 } | 2697 } |
| 2689 }; | 2698 }; |
| 2690 })(); | 2699 })(); |
| OLD | NEW |