user.sendEventImmediate ( hUser, "JPPackLoader", "onLoadLocalPacks" ) user.sendEventImmediate ( hUser, "JPPackLoader", "onSetLocalPath", sPath ) user.sendEventImmediate ( hUser, "JPPackLoader", "onLoadPack", sPackName, sPackURI ) user.sendEventImmediate ( hUser, "JPPackLoader", "onLoadPacksEnd" ) --User notification events: "onPacksLoadingDidEnd"
JPPackLoader is an AIModel that will allow you to load .stk files in your games. It will be useful for all packages offered below.
Once the AIModel is added to your game, the process to add a pack to your game is as follows:
Here is an example of loading and activation, with the JPAnimation pack (who must have been placed in your project root directory):
local hUser = application.getCurrentUser ( ) user.sendEventImmediate ( hUser, "JPPackLoader", "onLoadLocalPacks" ) JPAnimation.activate ( "" , "" )
Note that if the pack is stored locally, you can use the pack directly because it is loaded instantly when "onLoadLocalPacks" is called. However, some games may require to store the pack on a distant server, so the pack has to be downloaded and this process may take several frames. JPPackLoader is able to do it, and this is now a 2 steps process: download request made by you to JPPackLoader, and callback event sent to you by JPPackLoader when all the packs have been downloaded and are ready to be used. Here are the steps to follow:
local hUser = application.getCurrentUser ( ) user.sendEventImmediate ( hUser, "JPPackLoader", "onLoadPack", "JPAnimation", sUrl ) --Parameters areand --Do the same to request the download of any other pack here user.sendEventImmediate ( hUser, "JPPackLoader", "onLoadPacksEnd" ) --Tell JPPackLoader that all the download requests have been made to allow it to send the callback event when they all are downloaded
Simply send the "onLoadPacksEnd" event to inform JPPackLoader that all the pack requests have been made. JPPackLoader will notify you when they are all downloaded and ready to use with the "onPacksLoadingDidEnd" handler. You can start using your packs in this handler, starting with the activation:
function MyAIModel.onPacksLoadingDidEnd ( ) JPAnimation.activate ( "" , "" ) end