Back to Content
Mac OS X (.app) Target
When creating Mac OS X .app applications with CopperCube, there are some special features available:
Command Line Arguments
The single created .app file offers some command line arguments when starting it:
- -windowed Forces the application to be started in windowed mode instead of fullscreen mode.
- -debug Runs the application in debug mode. Makes the debug console visible for example, when an error happens or the
scripting environment pritns a line of text.
- -script:<file> Uses the given file as main script instead of the file compiled into the application.
Examples:
The following command line will start your application in windowed mode:
yourapplication.app/Contents/MacOS/yourapplication -windowed
The following will use a the script file 'myscript.js' instead of the compiled script and show the debugging console if some line of text is printed in your script. This is useful for example for developing the script file without the CopperCube editor.
yourapplication.app/Contents/MacOS/yourapplication -debug -script:myscript.js
Scripting with JavaScript
You can make your CopperCube 3D Mac OS .app scenes more interactive using a built-in scripting language named 'JavaScript'.
If you want to use this feature, do the following steps:
- Save your 3D scene to a file somewhere on your hard disk. For example to a file named test.ccb.
- Create a file named as your CopperCube file but with the extension '.js', for example test.js
- Edit this file with your favorite text editor (recommended: Notepad++, it
supports JavaScript syntax highlighting). When publishing your file now as Mac OS X .app, CopperCube will include this
script into the .app file and use it as main script.
Example:
Write this text in your .js file:
print("Hello World!");
When testing your 3D scene from the CopperCube editor, this will print the text 'Hello World' into the debug console.
CopperCube also provides a menu command so you can test if the syntax of your script is ok, use the Menu Command Tools -> Compile Main Script for this.
Development tip:
If you prefer to develop your script without the CopperCube Editor running, you can do this using the -debug and the -script: command line arguments. See Command Line Arguments for details.
Reference and Examples
There is a comprehensive JavaScript API scripting reference available in this documentation.
There is also a full example available: Movement with JavaScript.