[英]Javascript Phaser3 Assets Not Loading In Create Function
我正在尝试在 Phaser 的预加载 function 之外将基本图像加载到我的 Phaser3 游戏中,但没有任何效果。
我试过了:
dynImgLoader(textureKey,x,y,asset)
{
let loader = new Phaser.Loader.LoaderPlugin(this.scene);
loader.image(textureKey,asset);
loader.once(Phaser.Loader.Events.COMPLETE, ()=>
{
console.log('sprite ready for usage');
})
loader.start();
}
调用时,它仍然给我默认的移相器资产图像(未加载)
this.load.image('arc_red', arc_red);
this.load.onLoadComplete.add(this);
this.load.start();
还是不行。
问题:
如何在不使用预加载 function 的情况下为多人 web 套接字游戏“动态”加载资产? 为什么我做错了?
如果您在create
function (或其他非preload
函数)中使用此代码,它应该可以工作:
this.load.image(key, url); // add task
this.load.once('complete', callback, scope); // add callback of 'complete' event
this.load.start(); // start loading
我从这个文档中得到它,它在我的演示代码中工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.