简体   繁体   English

在浏览器(完整视口)中呈现JavaScript游戏的最佳解决方案是什么?

[英]What's the best solution for rendering a javascript game in Browser (complete viewport)

I think there are two diffrent solutions for the problem: 我认为该问题有两种不同的解决方案:

1) First the solution shown by aves Engine, which renders the whole game with html elements and external stylesheets eg CSS3 transfomations. 1)首先,由aves Engine显示的解决方案,该解决方案使用html元素和外部样式表(例如CSS3变形)渲染整个游戏。 Pro's are that the event-handling is much easier when working with div's than by rendering on canvas. 专业人士认为,与div一起使用时,事件处理要比在画布上进行渲染要容易得多。

2) Like isogenicengine.com shows you could render the game on html5 canvas element. 2)就像isogenicengine.com所示,您可以在html5 canvas元素上渲染游戏。 Mabye that's the better solution, because rendering on canvas is the way that millions of 2D-games were written before and in future the industry will optimize the drawing methods eg with hardware acceleration. Mabye是更好的解决方案,因为在画布上进行渲染是之前和将来数百万个2D游戏编写的方式,行业将例如通过硬件加速来优化绘制方法。 At the moment the contra is that rendering on canvas is slow if you would like to render in fullscreen. 目前,相反的是,如果要全屏渲染,则画布上的渲染速度很慢。 If you would like to render only in a specific area of 200x200px that's okay, but in fullscreen you get stuck with a framerate of 10fps. 如果您只想在200x200px的特定区域进行渲染,那是可以的,但是在全屏模式下,您会陷于10fps的帧率。

What do you think is the better way to create a game for the web? 您认为哪种更好的方式为网络创建游戏?

Thanks for your opinion! 感谢您的看法! PS: If you have some articles about the topic please paste some links PS:如果您有关于该主题的文章,请粘贴一些链接

I don't think it's a clear one size fits all kind of thing. 我认为这显然不是一种适合所有事物的尺寸。 I really think it depends on what you want to do with your game. 我真的认为这取决于您要如何处理游戏。

If you are doing a lot of vector graphic manipulation, perhaps canvas is a better choice vs engine like aves. 如果您要进行很多矢量图形操作,那么与aves这样的引擎相比,canvas是更好的选择。 For tiled based, maybe aves will work better. 对于平铺的,也许aves会更好。

You can render fast on fullscreen canvas if you're clever about only re-rendering dirty regions. 如果只对脏区域进行重新渲染,则可以在全屏画布上快速渲染。 But if your whole canvas needs to change every frame this obviously isn't going to help much. 但是,如果您的整个画布需要更改每个框架,那么这显然无济于事。

I've spent alot of time recently looking into this issue and my conclusion is pretty simple. 最近,我花了很多时间研究这个问题,结论很简单。

Use HTML Elements, lets say that HTML5 actually makes progress and in one year the major browser support it. 使用HTML元素,可以说HTML5实际上取得了进步,并且主流浏览器在一年内就支持它。 How long does it then take to get the general user base of the web on the latest browser (IE6 still has a choke hold in some sectors). 要在最新的浏览器上获得Web的一般用户基础需要花费多长时间(IE6在某些领域仍然处于停滞状态)。 So making the game available to as many people as possible is key! 因此,尽可能多的人使用游戏是关键! (In my mind anyways) (无论如何在我心中)

If however, your looking to learn and develop, go with canvas. 但是,如果您希望学习和发展,请选择画布。

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

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