Asset.ts 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import Hilo from "../hilo/Hilo";
  2. const Asset = {
  3. Mixes: Hilo.EventMixin,
  4. fire: Hilo.EventMixin.fire,
  5. on: Hilo.EventMixin.on,
  6. off: Hilo.EventMixin.off,
  7. queue: null as any,
  8. bg: null,
  9. man: null as any,
  10. bom: null,
  11. ground: null,
  12. ready: null,
  13. over: null,
  14. numberGlyphs: null,
  15. birdAtlas: null,
  16. holdback: null,
  17. load: function () {
  18. let host = "https://ssl.ycxxkj.com/demo_list/game_test1/dist/build/h5";
  19. var resources = [
  20. { id: "bg", src: host + "/static/images/map.jpg" },
  21. { id: "man", src: host + "/static/images/man.png" },
  22. { id: "bom", src: host + "/static/images/bom.png" }
  23. ];
  24. console.log("#debug#🚀 ~ file: Asset.ts:24 ~ resources:", resources);
  25. this.queue = new Hilo.LoadQueue();
  26. this.queue.add(resources);
  27. this.queue.on("complete", this.onComplete.bind(this));
  28. this.queue.start();
  29. },
  30. onComplete: function (e: any) {
  31. console.log("#debug#🚀 ~ file: Asset.ts:33 ~ Asset onComplete: Asset");
  32. this.bg = this.queue.get("bg").content;
  33. this.man = new Hilo.TextureAtlas({
  34. image: this.queue.get("man").content,
  35. width: 204,
  36. height: 375,
  37. frames: {
  38. frameWidth: 204,
  39. frameHeight: 375,
  40. numFrames: 13
  41. },
  42. sprites: {
  43. man: { from: 0, to: 12 }
  44. }
  45. });
  46. this.bom = new Hilo.TextureAtlas({
  47. image: this.queue.get("bom").content,
  48. width: 137,
  49. height: 135.31,
  50. frames: {
  51. frameWidth: 137,
  52. frameHeight: 135.31,
  53. numFrames: 16
  54. },
  55. sprites: {
  56. bom: { from: 0, to: 12 }
  57. }
  58. });
  59. this.queue.off("complete");
  60. this.fire("complete");
  61. }
  62. };
  63. export default Asset;