使用phaser框架开发h5小游戏,结果页游戏排行榜,phaser如何动态加载网络图片?

使用phaser框架开发h5小游戏的时候,最后有个游戏排行榜,其中就涉及到需要显示用户头像,在游戏过程中,phaser如何动态加载网络图片?

在phaser中正常使用一个图片,需要在preload中提取load出来

//加载图片
preload:function(){
          this.preload = function(){
            that.game.load.crossOrigin = 'anonymous'; // 设置跨域
            that.game.load.image('bg', '/game/game-bg.png');
          }
        }
        
        //使用图片
        created:function(){
          this.create = function(){
            that.game.add.tileSprite(0, 0,that.game.width,that.game.height, 'bg');
          }
        },
阅读 4.5k
1 个回答
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进