You are on page 1of 9

Application Development Kit

Programmer's Guide
Version 1.02

2009 Copyright © 1998-2009 Glenn Randers-Pehrson. Copyright © 2010 Creative Technology Ltd. The material in this document is the intellectual property of Creative and is provided solely for information. Creative accepts no liability for any consequences of its use. INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY. License for Lua 5. free of charge. Permission is hereby granted.org. 2 . Libpng version 1. While every care has been taken in the preparation of this document. TORT OR OTHERWISE. and to permit persons to whom the Software is furnished to do so. THE SOFTWARE IS PROVIDED "AS IS". merge. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM. to any person obtaining a copy of this software and associated documentation files (the "Software").0 and later versions Copyright © 1994–2008 Lua.2. Group 42. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.40-September 10. Inc. PUC-Rio. to deal in the Software without restriction. sublicense. Copyright © 1996-1997 Andreas Dilger. ARISING FROM. All rights reserved. WITHOUT WARRANTY OF ANY KIND. distribute. DAMAGES OR OTHER LIABILITY.COPYRIGHT Copyright © 2010 Creative Technology Ltd. EXPRESS OR IMPLIED. Copyright © 1995-1996 Guy Eric Schalnat. copy. WHETHER IN AN ACTION OF CONTRACT. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. You may not reproduce this document in whole or in part by any means. publish. and/or sell copies of the Software. Our products are under continual improvement and we reserve the right to change their specification without notice. All rights reserved. modify. subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. including without limitation the rights to use.

.. . . . .. .. Creating Your First Application . . . ... .. . All rights reserved. . . . . . .. . . . Copyright © 2010 Creative Technology Ltd... .. . . . . . . . ... .. . .. . . .. . . . . . . .Table of Contents Introducing ZEN X-Fi2 Application Development Kit .. . . . . . . . .. . . . .. . .... . . . 5 6 9 About the API Reference . . .. . . . . . . . .. . . . .. .. ... . .. 4 About the ZEN X-Fi2 Simulator . . . . 3 . ... .. .

The ZEN X-Fi2 ADK comes with the following: 1. scripting. API Reference – API stands for Application Programming Interface.html. Lua is dynamically typed. fast. making it ideal for configuration. 3. Copyright © 2010 Creative Technology Ltd. ZEN X-Fi2 Simulator – This application enables you to write and debug games and applications on your computer with the use of the Lua programming language. and has automatic memory management with incremental garbage collection. embeddable scripting language that combines simple procedural syntax with powerful data description constructs based on associative arrays and extensible semantics. you can easily develop your own games and applications on your Windows-based computer. What is Lua? Lua is currently the leading scripting language in games and is a powerful. Using this development kit.10. and rapid prototyping. All rights reserved. The API Reference document that comes with the ADK contains the predefined functions that you can use when your write your applications.org/about. To instantly access the API Reference. 4 . runs by interpreting bytecode for a register-based virtual machine.lua. To instantly access the Programmer’s Guide.* *This text is extracted from the Lua web site at http://www. 2. click Help on the ZEN X-Fi2 Simulator’s menu.Introducing ZEN X-Fi2 Application Development Kit With the use of firmware version 1. Programmer’s Guide – This document introduces the ADK and guides you in developing your own games or applications for ZEN X-Fi2. your ZEN X-Fi2 can support Lua-based games and applications that were developed using the ZEN X-Fi2 Application Development Kit (ADK). click Help on the ZEN X-Fi2 Simulator’s menu.04 or later. and then install them in your ZEN X-Fi2 player. lightweight.

You can instantly access this Programmer's Guide and the API Reference at any time from the Help menu. GUI.About the ZEN X-Fi2 Simulator When you run the ZEN X-Fi2 Simulator. you can see two windows: Creative ZEN X-Fi2 window This window simulates your ZEN XFi2's touchscreen. Note that applications that use audio and accelerometer functions can only be tested on the ZEN X-Fi2 player itself. 5 . All rights reserved. Log window This window shows the debug information. The default application list contains API demos for Sound. and Control libraries. You can test your new application on this window. Copyright © 2010 Creative Technology Ltd.

isTouch()==1 then screen.0.bmp file and save it inside the Hello ZEN folder. In the same folder.0. 2.color(oldcolor) screen. All rights reserved. This files should be inside a folder named similarly to the application.string. 1.fillrect(0.height.pos() string = "Hello ZEN!" text. The Hello ZEN application is then added in the Application list.color(red) x.size(30) oldcolor=text. 3.draw(x+20.width.read()==1 then if control.Creating Your First Application Your applications would require an icon file (icon.color(oldcolor) elseif control.width) screen.width() black = color.y = touch.update() text.new(0. Create the icon.width) screen.isButton()==1 then if button.png or icon. create the main.lua).height.bmp) and a script file (main."center".fillrect(0.click()==1 then break end end else os.size(30) oldcolor=text.0.png or icon.0) screen.height() width= screen. Copyright © 2010 Creative Technology Ltd.size(oldsize) text.update() text. Create a folder Hello ZEN under the directory C:\Creative\ZEN XFi2\Applications.sleep(10) end end 4.color(red) string = "Hello ZEN!" text.80.black) oldsize=text.lua file containing the following codes: --this is my first Lua application height = screen. The recommended resolution for the icon file is 50 x 70 pixels or less. The procedure below shows you how to make a simple application called "Hello ZEN".size(oldsize) text.update() while 1 do if control. 6 .new(255.black) oldsize=text.width.draw(0.0."left". Run ZEN X-Fi2 Simulator again.0) red = color.string.y.

For example: number = 0 string = “DEBUG-the number value is:”. the result will look like the sample snapshot below. When you click and drag the mouse on the screen.. You can use print() function in Lua script to print the value of the variable in the log window. 5.number print(string) The string will appear in the Log window. All rights reserved. Copyright © 2010 Creative Technology Ltd. 7 .When you click the program icon. the "Hello ZEN!" string will follow. Debug in ZEN X-Fi2 Simulator.

7. The Hello ZEN application is now added to the Application list in the player. Copyright © 2010 Creative Technology Ltd. All rights reserved. Copy the Hello ZEN folder into the Applications folder of your ZEN X-Fi2 player. 8 .6. Connect your ZEN X-Fi2 player to the PC via USB cable.

draw line. such as button press. accelerometer input. adjusting the volume. such as rotate screen. such as playing WAV files. taps/touches. changing channels. os. and others. and others. Captures action inputs.getenv() and os. Sound library Provides methods for audio functions.About the API Reference The ZEN X-Fi2 API Reference document includes the following libraries: Library GUI library Control library System library Description Provides methods for certain screen functions. draw image. Refer to the API Reference document for details.wait() are re-implemented in ZEN X-Fi2 ADK. 9 . Copyright © 2010 Creative Technology Ltd. All rights reserved.