Looking for the latest version? Download WhizJs v0.1.4 (51.2 kB)
Home
Name Modified Size Downloads / Week Status
Totals: 3 Items   5.5 kB 2
releases 2013-01-25 11 weekly downloads
README.md 2013-01-25 4.5 kB 11 weekly downloads
LICENSE.txt 2013-01-25 1.0 kB 11 weekly downloads

WhizJs Javascript Development Framework

This library consists of a set of classes and methods designed to simplify the development process when creating games or apps. Similiar to Flash's AS3, WhizJs provides a global stage object that controls the frame rate, alignment, scaling, and deminsions of your application. It's also where display objects are added and removed.

The WhizJs framework relies heavily on javascript's ability to create closures. A closure is a function within parenthesis that is instantly called, allowing properties and methods inside the closure to act as private variables.

WhizJs uses a package method, taking on a json syntax, that uses ES5's functionality to provide a better OOP working enviroment. It's responsible for packaging and returning a new class object. This means a class can extend another, allowing it to override and extend the functionality of it's parent class.

The graphics property provides an api for drawing lines, shapes, and text on sprites and shapes. Again, the api takes the form found in actionscript3.

WhizJs is released under the terms of a MIT license and depends only on a modern browser and a text editor to get started.

Usage

<!DOCTYPE html>
<html>
<head>
    <title>Getting Started w/ WhizJs</title>
    <script src="whiz.js"></script>
    <script>

// create a closure
(function() {
    // cache the classes
    var
    Event = whiz.events.Event,
    Sprite = whiz.display.Sprite,
    StageScaleMode = whiz.display.StageScaleMode;

    // package our main class
    package("Main", {
        extends : Sprite,

        constructor : function Main() {
            stage.width = 640;
            stage.height = 480;
            stage.frameRate = 30;
            stage.scaleMode = StageScaleMode.NO_SCALE;

            this.addEventListener(Event.ENTER_FRAME, function(e) {
                // execute some code each frame
            });
        }
    });
})();

    </script>
</head>
<body></body>
</html>

Here we've created a simple html document, a closure, and our main class.

The first parameter of package is a string containing the class name. In this case, we pass the value "Main". This is important because Whizdom will throw an error if the main class isn't found. If we wanted to use a preloader, we would use the value "Preloader". A preloader will override a main class definition.

The next parameter is the class definition. It's an ordinary javascript object that contains the parent class, extends, the class constructor, constructor, and, optionally, any other properties or methods you wish to add to the prototype of the class object being created.

Note: Properties and methods assigned to an object's prototype are shared among all instances of that object. This may not be the desired effect if you want seperate objects, including functions and arrays, assigned to the instances. Set the value of the object within the constructor to achieve this.

Within the constructor of the main class, properties can be set on the stage object, allowing you to customize the apps size, alignment, scaling, frame rate, and background color. The values shown are Whizdom's defaults. By default, the stage is rendered in the center of the window with a transparent background.

Attaching an event listern to this listens for the enterFrame event that will allow you to update your application or game each frame cycle.

License

WhizJs - Copyright © 2013 Winston Tamblyn http://whizjs.com/

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

  1. The code must retain the above copyright notice.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Source: README.md, updated 2013-01-25