|
AntTasks
PulpCore's Ant tasks
IntroductionThis file contains the documentation for PulpCore's Ant tasks used in the default build scripts, aimed towards developers who are creating custom build scripts or need to fine-tune asset conversion. Using the default build scripts, all you need to do is drop your assets in the "res" folder (project template) or the "src" folder (quick template) and the default build scripts handle it. SetupTo define the tasks, use: <taskdef resource="tasks.properties" classpath="${pulpcore.path}/pulpcore-assettools-0.11.jar"/>Assets TaskDescriptionCopies a directory of assets and converts images and sounds as needed. For each file, if the destination file exists and had a modified date greater than or equal to the source file, no action is taken. Therefore, this task only copies/converts assets that have changed since the last time this task was used. The following file types are passed to the Image task: PNG, GIF, BMP, SVG, and SVGZ. JPEG images are not sent to the image task, and instead are copied as-is. If a GIF file is an animated GIF, only the first frame is used. For each image, the Assets tasks checks if a coresponding properties file exists with the same name of the image, but with a .properties extension. For example, for res/player_left.png, the corresponding file res/player_left.properties contains the image metadata. Files ending in ".font.properties" are sent to the Font task. WAV files are sent to the Sound task. Parameters
Examples<pulpcore-assets srcDir="${res}" destDir="${build}/res" optimizationLevel="1" />Image TaskDescriptionConverts an SVG, GIF, or BMP image to an optimized PNG or optimizes an existing PNG. Optionally, metadata (hotspot, animation info) specified by a .properties file is added to the PNG. This task is called automatically from the Asset task, but can also be used for individual files. The Image task creates legal PNG files specifically for PulpCore's PNG reader. PulpCore was originally written for Java 1.1 - which does not have PNG support - so PulpCore needed its own PNG reader. This reader is still in use today because it is small, fast, and can easily extract metadata (animation info) from the PNG files. Parameters
Examples<pulpcore-image srcFile="${res}/myimage.gif" destFile="${build}/myimage.png" /><pulpcore-image srcFile="${res}/player.png" srcPropertyFile="${res}/player.properties" destFile="${build}/player.png" optimizationLevel="5" />Font TaskDescriptionCreates a PNG font from a .font.properties file. Parameters
Examples<pulpcore-image srcFile="${res}/title.font.properties" destFile="${build}/title.font.png" />Sound TaskDescriptionConverts a WAV file to PCM, signed, 16-bit, little-endian, mono or stereo. Valid sample rates are 8000Hz, 11025Hz, 22050Hz, and 44100Hz. If the WAV is already in a valid format, it is copied to the destination. If the WAV could not be converted to a valid format, a BuildException is thrown. This task is called automatically from the Asset task, but can also be used for individual files. Parameters
Examples<pulpcore-sound srcFile="${res}/mysound.wav" destFile="${build}/mysound.wav" />Applet TaskDescriptionCreates the index.html file based on a template, and copies the pulpcore.js file to the destination. Parameters
HTML templateThe HTML template needs to contain, at minimum, a @APPLET_PARAMS@ tag. Other optional tags are @BGCOLOR@, @FGCOLOR@, @TITLE@ (from the archive name), and @SRC@ (the source code from the displaySource parameter). Example: <html>
<head>
<title>@TITLE@ - Powered by PulpCore</title>
</head>
<body style="background: @BGCOLOR@; color: @FGCOLOR@">
<div>
<script type="text/javascript"><!--
@APPLET_PARAMS@
//-->
</script>
<script type="text/javascript" src="pulpcore.js"></script>
<noscript><p>To play, enable JavaScript from the Options or Preferences menu.</p></noscript>
</div>
<blockquote>
@SRC@
</blockquote>
</body>
</html>Examples<pulpcore-applet
destDir="${build}"
archive="HelloWorld.jar"
scene="HelloWorld"
assets="HelloWorld.zip"
displaySource="HelloWorld.java" /><pulpcore-applet
destDir="${build}"
archive="MyProject.jar"
scene="MyLoadingScene"
width="800"
height="600"
template="template.html"
splash="myslpash.gif"
params="text: 'Hello', color: '#0099ff' " />
|
Sign in to add a comment