如果我决定编写一个简单的文本和图形(2d)游戏,我可以使用什么库?假设我们使用 HTML5 兼容的浏览器。
我能想到的主要内容
- 在屏幕上渲染文本
- 动画精灵(使用图像/css)
- 输入(捕获箭头键并获取相对鼠标位置)
- 也许一些预加载资源或动态加载资源并选择顺序
- 声音(但我不确定有多重要)首先这对我来说)。也许是混合和链接声音或永远循环直到停止。
- 网络(低优先级)将一个用户连接到另一个用户或连续获取数据而无需多个请求(我知道存在这种情况,但我不知道它的设置或使用有多容易。但这对我来说并不重要。它是为了问题)。
If i decide to write a simple game both text and graphical (2d) what libs may i use? Assuming we are using a HTML5 compatible browser.
The main things i can think of
- Rendering text on screen
- Animating sprites (using images/css)
- Input (capturing the arrow keys and getting relative mouse positions)
- Perhaps some preloading resource or dynamically loading resources and choosing order
- Sound (but i am unsure how important this will be to me at first). Perhaps with mixing and chaining sounds or looping forever until stop.
- Networking (low priority) to connect a user to another or to continuously GET data without multiple request (i know this exist but i dont know how easy it is to setup or use. But this isnt important to me. Its for the question).
发布评论
评论(8)
嗯......有Rocket Engine。我没有使用过它,但它(表面上)似乎可以完成您想要的大部分工作。
我还推荐 HTML5 Gamer,这是一个关于在 HTML5/JS 中构建游戏的问题的博客
Well.... there's Rocket Engine. I haven't used it, but it appears (on the surface) to do much of what you want.
I'd also recommend HTML5 Gamer, a blog on the issues for building games in HTML5/JS
GameJs 这样做:
http://gamejs.org,免责声明:我是 GameJs 的开发人员。
上面的东西效果很好,我用它做了游戏。该 API 类似于 http://PyGame.org,有些人非常喜欢它。
网络已规划。
GameJs does this:
http://gamejs.org, Disclaimer: I'm dev of GameJs.
The stuff above works good and I did games with it. The API is similar to http://PyGame.org which some people like a lot.
Networking is planned.
如果您熟悉 jQuery,那么 gamequery 是一个不错的尝试。这是一个很好的演示,展示了您可以用它做什么:brainsnackers。
以下是一些功能:
If you're familiar with jQuery then gamequery is a good one to try. Here's a great demo of what you can do with it: brainsnackers.
Here are some of the features:
请查看 cake js。它已经存在很长时间了,而且用起来真的很好 - 特别是如果您以前使用过 ActionScript。
Check out cake js. It's been around a long time and it's really nice to use - especially if you've used actionscript before.
http://js1k.com比赛刚刚结束,2D平台游戏弹跳旁观者传奇(作者:marijnjh)是获奖作品。您可能需要查看源代码,因为它将提供非常容易掌握的横向卷轴概述,而无需阅读大量代码。
另一个不错的游戏是双人疯狂乒乓球,非常有趣。
另外,1kb 的游戏非常棒。
The http://js1k.com contest just ended and the 2D platform game Legend Of The Bouncing Beholder (by marijnjh) was the winning entry. You might want to look over the source since it would provide a very easy to grasp overview of sidescrollers without needing to read lots of code.
Another good one is the two-player crazy pong which is a lot of fun.
Plus, 1kb games are just awesome.
我会使用 RenderEngine 我认为它拥有您需要的一切,并解决了碰撞检测这一最重要的问题,而且它还有精灵支持...
教程 <- 这是一个很棒的教程,我发现
我希望这会有所帮助
i would use RenderEngine i think it has all you need and solves one of the most important problems that would be collision detection, and it also has sprite support...
Tutorial <- this is a great tutorial i found
i hope this helps
我可以推荐 Cometd 使用 ajax 推送网络(即 comet)
I can recommend Cometd for using ajax push networking (ie. comet)
createJS (createjs.com) 或 melonJS (melonjs.github.io/tutorial) 怎么样?
CreateJS 对您提到的这些项目有很好的支持,但不太确定网络。
MelonJS 原生支持读取 Tiledtilemap.tmx 文件。
What about createJS (createjs.com) or melonJS (melonjs.github.io/tutorial)?
CreateJS has great support for those items you mentioned, not so sure about networking though.
MelonJS has native support for reading Tiled tilemap .tmx files.