Skip to content
hugeen edited this page Nov 18, 2012 · 14 revisions

Structure

  • Create a file for the Skill component: /game/components/skills/skill_name.js
  • Add it to components loading file: /game/components.js

Your file should look like this:

define([
    'Underscore',
    'Crafty'
], function(_, Crafty) {
    
    Crafty.c("SkillName", {
        init : function() {
            this.cast = function(options) {
                // Do something here
            }
        }
    });

});

Add your skill icon

  • Add your icon (53*53) at the end of /assets/images/skills.png

Add it to the Skill Manager

  • Open /game/skills.js and add your skill
[{
    name: "SkillName",
    cooldown: 0.7,
    action: function() {
        Crafty.e("SkillName").cast(options);
    },
    backgroundPosition: "-53px 0"
}]

Add it to keyboard presets

  • Add a default key to /game/keyboard.js
AZERTY: {
    "SkillName": "Q",
},
QWERTY: {
    "SkillName": "A",
},
QWERTZ: {
    "SkillName": "A",
}

Congratulations you have just created a new skill!