【问题标题】:Phaser - Clean loadState and bootState cache DOMPhaser - 清理 loadState 和 bootState 缓存 DOM
【发布时间】:2017-01-21 23:16:51
【问题描述】:

我有一个Phaser.js 的游戏。我想清理所有loadStatebootState 缓存DOM,以删除图片链接。

我实际上使用Phaser.Cache 来删除Game DOM 中的所有缓存,它可以工作,但loadStatebootState 缓存仍然存在。

当我使用 Phaser.Cache 时

game.cache = new Phaser.Cache(game);
game.load.reset();
game.load.removeAll();

Game 缓存结果被清理

图像对象 { __default={...}, __missing={...}} __default Object { key="__default", data=img, base={...}, plus...} __missing Object { key="__missing", data=img, base={...}, plus...}

loadStatebootState缓存仍然存在

图像对象 { __default={...}, __missing={...}, 背景2={...},加上...} __default Object { key="__default", data=img, base={...}, plus...} __missing 对象 { key="__missing", data=img, base={...}, plus...} 背景对象 { key="background", url="数据:图像/jpeg;base64,/...q0xYqtMOKrDFiqz0sVf/9k=", 数据=img, 加上...}

【问题讨论】:

    标签: jquery image caching phaser-framework


    【解决方案1】:

    你需要清除每个状态

    game.state.clearCurrentState(); 
    

    移相器文档说:

    此方法清除当前状态,调用其关闭回调。 该过程还删除任何活动补间,重置相机,重置 输入,清除物理,删除计时器,如果设置清除世界和 缓存。

    你也可以使用

    game.state.destroy(); // Removes all StateManager callback references to the State object, nulls the game reference and clears the States object
    

    【讨论】:

    • 感谢您的良好回复。此解决方案清除并重置我所有的游戏对象视觉。我想保留所有创建的对象,只清理缓存状态。使用game.cache = new Phaser.Cache(game); game.load.reset(); game.load.removeAll(); 只会清理缓存。你有办法做这个吗?
    • 我认为Phaser不能做到这一点。
    猜你喜欢
    • 1970-01-01
    • 2012-06-29
    • 2012-07-08
    • 1970-01-01
    • 2017-02-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多