Skip to content

Clojure app to generate phzr code from Phaser javascript source

License

Notifications You must be signed in to change notification settings

dparis/gen-phzr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gen-phzr

Generate phzr clojurescript files based on JSON data built from parsing jsdoc comments in Phaser javascript source.

Usage

Prerequisites

Generate jsdoc JSON

To generate the resources/phaser.json file required by gen-phzr, first change into the resources/phaser-src directory. Then run the following commands:

grunt clean
grunt pixidoc
grunt gitclone:plugins
grunt jsdoc:json

Install whatever grunt/node packages are necessary to make those commands run successfully. Once they've all run without error, copy the generated JSON file into the gen-phzr project resources:

cp out/docs.json ../phaser.json

Generate phzr code

Change back into the gen-phzr project root directory and run:

lein run

All generated files will be copied into the out/ directory.

Manual Edits

Some generated files require hand-tweaking because:

  1. I am lazy and the code to fix them programmatically is somewhat cumbersome

Apply the following changes once the source files have been generated:

Fix array-set/call-all - 2015-08-15

The array-set/call-all function should take varargs. This is not conveyed by the jsdoc JSON clearly. The function def should look like:

(defn call-all
"Calls a function on all members of this list, using the member as the context
for the callback.

  If the `key` property is present it must be a function.
  The function is invoked using the item as the context.

  Parameters:
    * array-set (Phaser.ArraySet) - Targeted instance for method
    * key (string) - The name of the property with the function to call.
    * parameters (*) - Additional parameters that will be passed to the callback."
  ([array-set key & parameters]
   (phaser->clj
    (.callAll array-set
              (clj->phaser key)
              (clj->phaser parameters)))))

Add keyboard key constants - 2015-08-15

The Phaser.Keyboard class has a bunch of undocumented constants so the accessor map for those will have to be added to the impl/accessors/keyboard.cljs file manually.

As well, the phzr.keyboard/const function will need to be defined as follows:

(defn const
  [k]
  (when-let [cn (get phzr.impl.accessors.keyboard/keyboard-constants k)]
    (aget js/Phaser.Keyboard cn)))

Bugs

I'm sure there are some. This app was cobbled together hastily in order to get phzr up and running. Maybe someone will find it useful? I hope so!

Copyright © 2015 Dylan Paris

Distributed under the MIT license.

About

Clojure app to generate phzr code from Phaser javascript source

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published