forked from craftyjs/Crafty
-
Notifications
You must be signed in to change notification settings - Fork 1
Modules
ahilles107 edited this page Jan 13, 2012
·
11 revisions
A way for game developers to share components and other common game logic.
What we have?
- craftycomponents.com where description and links to cdn are available of all components.
- Specify component name/version. something like
Crafty.modules({ moveto: 'DEV' }, function () {
//module is ready
});
- Use the component in the game as if it was defined locally: Crafty.e("MoveTo")
We use scriptjs to load the components http://dustindiaz.com/scriptjs
- It's possible to load components at arbitrary points in time so stuff that is only needed in late levels don't delay start of the game.
- callback when a component is ready
- commit-hook pointing to craftycomponents.com
- jsfiddle support
- comments for component (disqus)
TO DO:
- for performance we could make it possible to bundle a bunch of modules in one file or even combine it into the game source.
- rating system for componets
Module lives in their own repository on github. Any one can add it to craftycomponents.com through page. In the root of the repository is a package.json file with information about name, version, description etc. to be displayed on the modules website. Whenever the version changes we grab the code, minifies and publish to s3 under a naming system that the crafty script loader understands.
If version 1.8, 1.9 and 2.1 exists these files are created:
- cdn.crafty-modules.com/modulename-1.8.js - 1.8
- cdn.crafty-modules.com/modulename-1.9.js - 1.9
- cdn.crafty-modules.com/modulename-2.1.js - 2.1
- cdn.crafty-modules.com/modulename-DEV.js - Latest checkin (even if version wasn't updated)
- cdn.crafty-modules.com/modulename-RELEASE.js - Latest checkin where version changed (2.1)
TO DO:
- cdn.crafty-modules.com/modulename-1.x.js - 1.9
- cdn.crafty-modules.com/modulename-2.x.js - 2.1
- cdn.crafty-modules.com/modulename-DEBUG.js - As DEV, but not minified
{
"name": "MoveTo",
"version": "1.0",
"title": "Move entity towards mouse",
"author": {
"name": "Søren Bramer Schmidt",
"url": "https://github.com/sorenbs"
},
"licenses": [
{
"type": "MIT",
"url": "MIT-LICENSE.txt"
}
],
"dependencies": {
"Mouse": ">0",
"Crafty": ">0.4"
},
"description": "The mouse equivalent of Fourway. Click and the entity will move toward the point. NewDirection event will be triggered",
"keywords": [
"mouse",
"move"
],
"jsfiddle" : "http://jsfiddle.net/zalun/NmudS/embedded/",
"homepage": "https://github.com/sorenbs/MoveTo",
"files": [
"moveto.js"
]
}
//If You don't want example tab just write "jsfiddle" : "disable",