1 decade ago
by Gal
Is it possible to set game size to specific width/height?
The game is "auto" scaling to screen width/height, but i need to be able to set it to my specific dimensions
(Don't ask why...;-)
Is there a way to "scale" all game to specific width/height or scale?
I looked into the forums, and it looks like i need to change each entity, each image, each font, etc...
Is there something easier?
for example, something like: setGameSize(400,300);
Thanks,
Gal Tamir...
1 decade ago
by Joncom
Know what scale you want to use ahead of time, because scale is mostly likely not something you want to be changing on the fly. Your
main.js
should look something like this:
ig.module('game.main')
.requires(
'impact.game'
)
.defines(function(){
MyGame = ig.Game.extend({
// ...
});
var scale = 1;
var width = 400;
var height = 300;
ig.main('#canvas', MyGame, 60, width, height, scale);
});
By the way, your game should not be "auto-scaling" unless you told it to. That is not the default. Are you using vanilla ImpactJS or something else like Impact++?
1 decade ago
by Gal
I know about that option, but i need it to be resized during the game...
For example,
Lets say that the game is using 3/4 of the page, and lets say i have a "collapseable chat" area near the game, and i want to change the game size when the chat is opened.
The game should continue the same, but resized to new size when i have a message on the chat...
Any ideas how to do Resize the game while it is running?
Thanks,
Gal Tamir.
1 decade ago
by Joncom
How to make the canvas always fill the window:
ig.module('game.main')
.requires('impact.game')
.defines(function(){
MyGame = ig.Game.extend({
init: function() {
window.onresize = this.onresize;
},
onresize: function(event) {
var width = Math.floor(window.innerWidth/ig.system.scale);
var height = Math.floor(window.innerHeight/ig.system.scale);
ig.system.resize(width, height);
}
});
var scale = 1;
var width = Math.floor(window.innerWidth/scale);
var height = Math.floor(window.innerHeight/scale);
ig.main('#canvas', MyGame, 60, width, height, scale);
});
Page 1 of 1
« first
« previous
next ›
last »