LogoPixi’VN

资源

本文介绍如何在Pixi'VN(Ink)中定义、初始化和加载资源,涵盖资源矩阵设置、Ink加载/懒加载命令、清单示例及资源别名等内容。

正如在这里所更详细解释的那样,建议在项目开始时初始化资源矩阵,预先加载资源,并规划好资源的加载时机。

Ink中,你对于资源加载方式和时机的控制力显然不如使用JavaScript/TypeScript的时候灵活。 为此,Pixi'VN在Ink中提供了一个单一函数,用于在标签( label )开始前加载资源。 你需要使用以下语法:

file_type_ink
ink
# {operation} {assets or bundle} {list of URL/path of the image}
  • #: is the hashtag symbol to identify a hashtag command.
  • operation: the operation to perform. Currently supported:
    • load:使用await方式加载资源或资源包(对应Assets.loadAssets.loadBundle)。
    • lazyload:在后台静默加载资源或资源包(对应Assets.backgroundLoadAssets.backgroundLoadBundle)。
  • assets or bundle:要加载的资源类型。 可用类型包括:
    • assets:加载assets。
    • bundle:加载bundle。
  • list of URL/path of the image:要显示的图片(或者其他资源)的URL/路径列表。 如果你已经初始化了资源清单,你可以直接使用纹理别名代替URL。 注意:在ink中写https://时必须写成 https:\/\/,因为//Ink中会被视为注释。
=== start ===
# lazyload bundle main_menu start
# load assets eggHead flowerTop my_video
# show image eggHead
# show image flowerTop
# show video my_video
# pause
-> start