开发者

scallable javascript games

How is this JavaScript based games scallable? http://www.codedread.com/yastframe.php When you resize the browser window the games scales nicely to fit the window.

Is it because of the use of SVG?

I also have to create different games/educational lessons and other stuff that I want to fit nicely in any resolution like Flash.

I did read somewhere that SVG is resolution independent. But I've开发者_JAVA百科 no idea how to take advantage of that.


It's a frameset with the following ratio:

cols="130,*,130"

The mid frame (the game) width is thus (page width) - 2 * 130. The SVG has been set to width="100%" height="100%" and will fill the complete mid frame. As you resize your window, the 100% will become something else when calculated in absolute pixels and the game will resize along.

Since the viewbox is 0 0 800 600, it will automatically keep the ratio. Try changing it (using a DOM inspector) to e.g. 0 0 800 800. You will see the game move to the top a little, since the height has become more and the game has to move up to make space.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜