Import ZIP files (new levels)

Hi guys. I would like to ask you about one important thing. I know AS3 and Starling
very well but I would like to prepare my new game in Defold. I already know the basics of Defold but I wonder how I can import extra game levels from server to my application.

The general users will be able to buy additional levels that will be associated with the game.
These will be ZIP packages in which there will be graphic, text and mp3 files.
The ZIP file must be downloaded, unpacked and uploaded to the appropriate directory (Android and iOS). Is it difficult to achieve in Defold ?

The problem with what you’re describing with the zip file containing music and assets is that Defold doesn’t support loading of music/sfx from any source and then playing them. It’s possible using the OpenAL extension in the Asset Portal though.

When it comes to graphics it’s possible to load PNGs using the PNG extension and you can using existing Defold APIs load images and use as textures for GUI nodes. For anything more complex such as using a downloaded image in a tilemap or as a sprite flipbook you’re unfortunately out of luck.

A much better approach in my opinion would be to unlock and track bought content some other way and then serve it using our Live Update feature where assets (tilemaps, atlases, tilesources, spine objects and any other Defold assets) and scripts can be downloaded and cached in the client and then used using the normal Defold APIs

BTW, is this a desktop game? If it’s a mobile game then payment could be handled through in-app purchases.

The mobile version (Android and iOS) is a priority, but I would like to give a demo at WWW.

Because the levels of the game will not be like in standard games. You can choose levels yourself.
Therefore, it is necessary to pull in and delete old levels so that the application is not too large.
Each user can have other active levels, a different configuration.

Ok, I understand. What kind of game is it? How is a level designed? Is it a tilemap based game or is it created from multiple positioned game objects?

2 Likes

This will be an educational game. Elements of the level in the package will generally be questions and answers.
The questions include:

  • text questions (from text file)
  • questions in the form of illustrations (jpg or png)
  • mp3 recordings

Ok, sounds fairly doable.

Not a problem. Store them on disk and read them using the io.* functions. To work with iteration of files in a folder you need the LuaFileSystem extension.

Not a problem. Load and display jpg or png images using image.load() and set on a gui box node. Example of loading and setting a texture on a box node. If you want to use a sprite component instead of a box node your best bet is to load png images using the Png Extension. Check example here.

This is tricker. Defold supports .ogg and .wav files and it’s currently not possible to load and play sounds from disk at runtime without an extension. You can use the OpenAL extension to load and play wav files from disk. We currently have no MP# extension.

2 Likes

I’m happy :slight_smile: And how to unpack files? In AS3 I have special extensions for ZIP files. This is really a systemic solution.

Defold has built in zlib support via zlib.deflate() and zlib.inflate(). If you need other compression formats those should be fairly easy to add as native extensions.

1 Like

@britzl - Thank you very much !