I am currently trying to learn how to use crafty.js to create games. Right now the square sprite is drawn, but I am unable to get it to do anything. Here is the code for my game:
Game = {
// Initialize our game
start: function() {
// Start crafty and set a background color
Crafty.init(640, 480);
Crafty.background('green');
Crafty.sprite(16, "assets/square.png", {square:[0,0]});
Crafty.c('SquareControls', {
init: function() {
this.bind('enterframe', function() {
this.x = this.x+2;
});
return this;
}
});
//// SCENES ////
Crafty.scene("main", function() {
var square = Crafty.e("2D, Canvas, square, SquareControls")
.attr({x:32, y:32, width:16, height:16});
});
Crafty.scene("main");
} // end start()
} // end Game class