Coder Social home page Coder Social logo

gen-phzr's Introduction

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.

gen-phzr's People

Contributors

dparis avatar

Stargazers

ebigram avatar Oleg Martynov avatar Paul Bunkham avatar @cdcme avatar Vasiliy Yorkin avatar  avatar Josh Mize avatar  avatar Vladimir Sh avatar Eric Bailey avatar Dmitri Sotnikov avatar Mike Konkov avatar

Watchers

 avatar Vladimir Sh avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.