JavaScript 6
ES6 WITH ZIM
You can code ZIM with ES6 (JavaScript 6). See an EXAMPLE page.- const and let instead of var (or still use var)
- arrow functions: ()=>{} instead of function(){} (or still use function(){})
- `` for multiline strings and ${templating}
- let [a,b] = [7,9] destructuring
- the [...spread, operator]
- class, extend, super, get, set for OOP
- and more!
ES6 MODULES
ES6 Modules can be imported for ZIM and helper libraries. See the IMPORT examples. (The imports include CreateJS as well.)
<script type="module">
// note the type="module" in the script tag above
// alternatively, use script tags - see https://zimjs.com/script
import zim from "https://zimjs.com/cdn/018/zim";
new Frame(FIT, 1024, 768, light, dark, ready);
function ready() {
// put your code here
new Circle(100, blue).center().drag();
}
</script>
// USE ANY OF THESE (or combinations):
// REGULAR
import zim from "https://zimjs.com/cdn/018/zim";
// GAME
// for ZIM plus game module
import zim from "https://zimjs.com/cdn/018/zim_game";
// PHYSICS
// for ZIM plus Box2D plus physics module and game module
import zim from "https://zimjs.com/cdn/018/zim_physics";
// SOCKET
// for socket.io plus socket module
import zim from "https://zimjs.com/cdn/018/zim_socket";
// THREEJS
// for ZIM plus three module and three.js
// and OrbitControls, ObjectControls, FirstPersonControls,
// PointerLockControls, and GLTFLoader
import zim from "https://zimjs.com/cdn/018/zim_three";
// CAM
// for ZIM plus cam module
import zim from "https://zimjs.com/cdn/018/zim_cam";
// PIZZAZZ
// for ZIM plus pizzazz modules 1, 2, 3
import zim from "https://zimjs.com/cdn/018/zim_pizzazz";
// MULTIPLE MODULES
// for ZIM plus three plus pizzazz modules
// the names at front do not matter - they just must be different
import zim from "https://zimjs.com/cdn/018/zim_three";
import piz from "https://zimjs.com/cdn/018/zim_pizzazz";
// TEST
// for unminified ZIM (better error messages)
import zim from "https://zimjs.com/cdn/018/zim_test";
// LOCAL
// for local versions of a module add the .js extension
import zim from "local/zim.js";