Android开发-鸟瞰2D地图
我正在考虑创建地图的 2D 鸟瞰图,用户基本上可以在其中浏览地图。
有没有一种方法可以让我一次性创建整个地图并将其存储在某个地方,然后在游戏过程中仅显示该地图的特定部分? 例如,地图大小=100 x 100,但用户只能看到5x5(放大后占据屏幕的70%)。
I am looking at creating a 2D birdseye view of a map where the user is basically working their way through it.
Is there a way that I can create the whole map in 1 go and store it somewhere, then simply only display a certain section of that map during game play?
e.g map size =100 x 100 but user can only ever see 5x5 (which is zoomed-in to use up 70% of the screen).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果将整个 100x100 贴图作为位图/纹理存储在内存中并且仅显示特定部分,则可能会使用过多内存。我认为如果你将它分成例如 5x5 的块并缓存这些块(仅那些现在可见和绘制的块),你会更高兴。当用户移动并到达新块时,您只需在位图/纹理上绘制 5x5 的图块,并在其可见(且未更改)时将其缓存。
It might use too much memory if you store the whole 100x100 map as a bitmap/texture in memory and only display a certain part. I think you'll be more happy if you divide it into chunks of e.g. 5x5 and cache these chunks (only those that are visible and drawn right now). When the user moves and gets to a new chunk, you just draw the 5x5 tiles on a bitmap/texture and cache it for as long as it's visible (and unchanged).