I am really new to craftyjs and I wrote a new game that created a full screen canvas. The game creates instance of board that draw a board with size of boardSize X boardSize:
var Game = {
start: function() {
Crafty.init();
var boardSize = Math.min(window.innerWidth, window.innerHeight);
Crafty.e('Board').board(boardSize);
}
};
I would like the board to be changed on resize according to the new window size. How can I do that?
You could subscribe on window resize event and change the Board component size accordingly. Example:
window.onresize = function() {
var boardSize = Math.min(window.innerWidth, window.innerHeight);
Crafty(Crafty('Board')[0]).board(boardSize);
};