Asset Packaging

So I’m hoping to put out a beta/demo version of my current project soon, and I was wondering what one might use for packaging it up. That is, in particular, I want to protect the game assets so that they aren’t just sitting out there for anyone to copy and use. I’m totally new at this sort of thing so I’m not sure where to start or if I have to make some sort of concession in the actual game code itself for this.

Have you tried embed="true"?

Good grief, is it that easy? Do I put the “embed” command in the project.xml somewhere?

Like this?

<assets path="assets/sfx" rename="sfx" embed="true" />

If so, I ended up with this when I compiled:

Error: Buffer.add: cannot grow buffer

EDIT: OK, something is REALLY screwed up. I just fired up a different project on a windows build and its doing the exact same thing as described below.


OK, I have a very serious issue now. I manage to get the compile to run with “embed” on some of my assets. However, now all I’m getting when the game starts is a black screen. Everything is supposedly still running: I can hear sound and if I click the mouse where a menu button is supposed to be, it responds appropriately (audibly, at least.) I’m currently using OpenFL 3.6.1 but upgrading is not optimal since I’m nearing the end of my current project.

I turned off embed and it still doesn’t fix it.

I reverted back to my last good build and it still doesn’t fix it.

Nuking the entire “bin” file to ensure a clean build doesn’t fix it.

The project.xml is one of the few things that isn’t tracked by the repository though. Does anyone see anything wrong here?

<?xml version="1.0" encoding="utf-8"?>
<project>
	<!-- NMML reference: https://gist.github.com/1763850 -->
	
	<!-- metadata, make sure 'package' is at least 3 segments (ie. com.mycompany.myproject) -->
	<meta title="Glyphs" package="Glyphs" version="1.0.0" company="Brendan Wiltshire" />
	
	<!-- output -->
	<app main="Main" file="Glyphs" path="bin" />
	
	<window background="#FFFFFF" fps="60" />
	<window width="800" height="480" unless="mobile" />
	<window orientation="landscape" vsync="false" antialiasing="0" if="cpp" />
	
	<!-- classpath, haxe libs -->
	<source path="src" />
	<haxelib name="openfl" />
	<haxelib name="actuate" />
	
	<!-- assets -->
	<icon path="assets/openfl.svg" />
	<assets path="assets/data" rename="data" />
	<assets path="assets/font" rename="font" />
	<assets path="assets/img" rename="img" />
	<assets path="assets/puzzles" rename="puzzles" />
	<assets path="assets/music" rename="music" />
	<assets path="assets/sfx" rename="sfx" />
	
	<!-- optimize output
	<haxeflag name="-dce full" /> -->
	
</project>

Can you try OpenFL samples, and see if they work?

Compiled Pirate Pig and BunnyMark to Windows. Could hear the audio from Pirate Pig but both were once again black screens.

Really strange this one is. It seems like the “embed” command flipped some switch inside the Haxe or OpenFL internals.

Are there any errors in the console? Does openfl test windows -Dcairo work differently?

No errors in the console.

I’m not overly familiar with the command line options. I generally use the options set up by the FlashDevelop OpenFL template. Currently, this is what the pre-build command line looks like:

"$(CompilerPath)/haxelib" run lime build "$(OutputFile)" $(TargetBuild) -$(BuildConfig) -Dfdb

Are you asking me to change “lime” to “openfl” and “-Dfdb” to “-Dcairo”? If so, I tried that and there was no difference in appearance. Or do I need to build it like normal and use the command prompt to test it with your command? I tried this:

openfl test "C:\Users\Brendan\Documents\OpenFL Projects\Glyphs\project.xml" windows -Dcairo

Still had a black screen but there was no audio either.

Does your project work on HTML5?

Did you try reinstalling OpenFL and Lime?

I’d have to change some things around for HTML, because its referencing .ogg audio files right now. That being said, the other projects (including the other one of mine I mentioned earlier) do work with HTML5.

I could try reinstalling OpenFL, but as I said before I’m not super familiar with command prompt stuff. I know I can “remove” and then (re)install a specific version, but how do I make sure my FlashDevelop projects don’t have their library references broken? Like I said, I’m very close to the end of my current project and I want to be careful not to screw anything else up.

Couple of easy commands that might help. Just open a cmd window.

haxelib list
Will show all installed libraries and the current version in use in square brackets.

haxelib install openfl
Will install latest version and set it as your current version.

haxelib install openfl 5.1.5
Will install specified version and set it as your current version.

haxelib set openfl 3.6.1
Sets the specified, already installed, version as your current version.

I think you can also use this in your project.xml to specify version to use.
<haxelib name="openfl" version="3.6.1"/>

You don’t need to remove other versions and can have multiple versions installed.

Hope it helps.

Right, but if I try to install openfl 3.6.1 (what I have,) it tells me its already installed. Obviously I can remove it, but I need to make sure it’ll reconnect to my FlashDevelop projects once its reinstalled.

Just to be clear, its my understanding that trying version 4+ isn’t feasible because of the Tilesheet/Tilemap switch up.

that’s what this is for. It will set it back to 3.6.1 if you want.

or use this in your project.xml.

EDIT: About the Tilesheet/Tilemap , that might be. I don’t know what to do about your other problems, but thought I’d show the way to switch between versions.

I think I see what you’re saying now, but my project.xml doesn’t even have any “haxelib” elements. It makes me wonder where FlashDevelop is getting the references then. I did notice the “classpaths” under project properties, but those don’t appear to be editable.

I see you have this from post above ^

<haxelib name="openfl" />
<haxelib name="actuate" />

This is where FlashDevelop is getting the classpaths. It uses the currently set versions, which you can set with the command prompt haxelib set openfl 3.6.1

Ahahaha… excuse my blindness. :stuck_out_tongue:

:slight_smile: you shouldn’t be worried trying different versions, you can easily change them back with set.

Good luck with the other problem.

The reinstall got rid of the black screen. Brilliant. :smiley:

Looks I can go back to fussing with the “embed” stuff and see what happens.

1 Like

OK, so I can successfully embed the image and sound effect files, but when I try to do the music I get the “buffer.Add” error in the console. Based on the searches I did here, that’s a size restraint issue that can’t be circumvented, correct?

Are there any other facilities through Haxe or OpenFL through which I could “hide” the music?