简体   繁体   English

适用于任何分辨率的HTML5 JS游戏

[英]HTML5 JS Games that works on any resolution

We are going to create a bunch of educational contents like lesson, exercise and games for children to be used on OLPC xo. 我们将为儿童制作一系列教育内容,例如课程,运动和游戏,供OLPC xo使用。 We are going to use HTML5 and JavaScript. 我们将使用HTML5和JavaScript。 Previously they had used Flash. 以前,他们曾使用Flash。

The xo has 900x1200 resolution. xo的分辨率为900x1200。 The content though created primarily for xo, will be used online also. 内容虽然主要是为xo创建的,但也将在线使用。 The content created previously in Flash scales well in any resolution. 以前在Flash中创建的内容可以在任何分辨率下很好地缩放。 What should I do to have the same behavior in HTML5+JS content. 我该怎么做才能在HTML5 + JS内容中具有相同的行为。 so far few of the sample content has used fixed resolution of 900x1200 resolution with absolute positioning. 到目前为止,几乎没有样本内容使用绝对定位的900x1200固定分辨率。 They look great on xo but doesn't look great on variety of resolution in desktop computers. 它们在xo上看起来很棒,但在台式机上的各种分辨率上看起来都不好。

Any help/guidance will be much appreciated. 任何帮助/指导将不胜感激。

Instead of fixed resolution, dynamically calculate the size of the window and initialize other parameters. 动态计算窗口大小并初始化其他参数,而不是固定分辨率。 'window.innerHeight' and 'window.innerWidth' will check the size available on the browsers' window. “ window.innerHeight”和“ window.innerWidth”将检查浏览器窗口上的可用大小。 Or make use of 'screen.height' and 'screen.width' to calculate the screen's resolution dynamically. 或者使用“ screen.height”和“ screen.width”动态计算屏幕的分辨率。 Let me know if you need clarifications. 让我知道您是否需要澄清。

You can scale web content easily using transform: scale(scaleRatio); 您可以使用以下transform: scale(scaleRatio);轻松缩放Web内容transform: scale(scaleRatio); CSS property. CSS属性。 Though this is a part of CSS3 standard the most of the browsers now use specific prefixes for this property like: -moz, -webkit, -ms, -o. 尽管这是CSS3标准的一部分,但大多数浏览器现在都为此属性使用特定的前缀,例如:-moz,-webkit,-ms,-o。

You can read more about transform on MDN . 您可以阅读有关MDN transform更多信息。

Tom here from Scirra, we're a 2 man team who are making an HTML5 game engine called Construct 2 you might want to look at as it sounds like it might be right up your street. 来自Scirra的Tom,我们是一个由2人组成的团队,他们正在制造一个称为Construct 2HTML5游戏引擎,您可能想看看它似乎就在您的街道上。

Construct 2 can handle multiple screen sizes, it's crucial for deployment of HTML5 games and apps to mobile devices that sport many resolutions. 构造2可以处理多种屏幕尺寸,这对于将HTML5游戏和应用程序部署到具有多种分辨率的移动设备上至关重要。 Check out our tutorial on how to manage this in Construct 2: 查看我们的有关如何在“构造2”中进行管理的教程:

http://www.scirra.com/tutorials/73/supporting-multiple-screen-sizes http://www.scirra.com/tutorials/73/supporting-multiple-screen-sizes

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM